• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

XF 1.4 Conditionals for Secondary Usergroups

#1
Yes, I know I am not the first to ask about this. I did do a search and saw that others have asked before, but for some reason, the solutions provided there don't seem to be working for me and I am not sure what I am doing wrong.


All of our members have Registered Members as their primary usergroup.

We have a usergroup called Full Members which members are promoted to automatically after being a member for 90 days AND making 50 posts. This is a secondary groups and provides a few bonuses for members like being able to create threads in certain forums.

We want to limit ads for members who have the Full Members usergroup as their secondary group (keep in mind, their primary group is still Registered Members).

Full Member is group 6

Registered Member is group 2

Looking at @Brogan 's Conditional Statements, we added:

<xen:if is="!{xen:helper ismemberof, $visitor, 6}">
Ad content
</xen:if>


After adding this conditional, all members, including those with the Full Member secondary group still show the ad.

After reading this thread:
https://xenforo.com/community/threa...ndary-usergroups-in-templates-possible.42461/

I changed the code to:
<xen:if is="!{xen:helper ismemberof, $user, 6}">
Ad content
</xen:if>

Same result. Everyone sees the ad.

After reading this thread:
https://xenforo.com/community/threads/secondary-user-group-conditional.35597/

I changed the code to:
<xen:if is="{xen:helper ismemberof, $visitor, 6}">
<xen:else />
Ad content
</xen:if>
Same result. Everyone sees the ad.

Now... if I go with a completely different conditional, such as:


<xen:if is="{$visitor.message_count} < 50">
Ad content
</xen:if>

It works exactly as expected... but I don't want that to be the conditional. I want to base it off group membership.

What am I doing wrong?
 

Brogan

XenForo moderator
Staff member
#2
This should work.

5. How can I hide content from a specific user group?
<xen:if is="!{xen:helper ismemberof, $visitor, x}">
This content will be hidden from members of user group x
</xen:if>
 
#4
I hate to dredge this up, but I am having the same problem.

<xen:if is="{xen:helper ismemberof, $visitor,1,2,3,13,20,26}">
does not work because when members upgrade, their secondary group, ,not their primary group, is changed, and I can't find the code for secondary group checks.
 
#6
Hi. Did you find any solution to this? I've read about 20 threads and have no answer.

What I want to achieve is simple.

I have a secondary group number 49.

I want to show an advert to everyone EXCEPT those with 49 as a secondary group.

But it's alluding me.
 

Martok

Well-known member
#7
Hi. Did you find any solution to this? I've read about 20 threads and have no answer.

What I want to achieve is simple.

I have a secondary group number 49.

I want to show an advert to everyone EXCEPT those with 49 as a secondary group.

But it's alluding me.
The answer is in post #2. Replace x with 49. It does work as I use this code on my site to hide ads from a specific usergroup.
 
#8
You know, I tried that multiple times I swear... just did it, and it worked.

Totally bemused... but thank you fro making me revisit it!