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

Usergroup conditionals

Chris D

XenForo developer
Staff member
#2
What do you mean "view a certain user group"?

If you're talking about hiding/showing content to specific usergroups, you can do this:

Code:
<xen:if is="{xen:helper ismemberof, $visitor, 999}">
      Visitor is member of usergroup ID 999
</xen:if>
 

Chris D

XenForo developer
Staff member
#4
That's not quite what you asked for, but ok.

It will save you a lot of time and frustration if you just explain in advance what you're wanting to do in detail.

Using the Notable Members list as an example, the template has this:

Code:
                <xen:foreach loop="$staff" value="$user">
                    <li><xen:avatar user="$user" size="s" text="{$user.username}" class="Tooltip" title="{$user.username}" /></li>
                </xen:foreach>
So you could copy that several times and add a very similar conditional to what I used above for each usergroup you want to show:

Code:
               <div class="staffHeader">Moderating Staff</div>
                <xen:foreach loop="$staff" value="$user">
                   <xen:if is="{xen:helper ismemberof, $user, 4}">
                        <li><xen:avatar user="$user" size="s" text="{$user.username}" class="Tooltip" title="{$user.username}" /></li>
                   </xen:if>
                </xen:foreach>
So, something like that.
 

Chris D

XenForo developer
Staff member
#6
In the member_notable template, find this:

Code:
                <xen:foreach loop="$staff" value="$user">
                    <li><xen:avatar user="$user" size="s" text="{$user.username}" class="Tooltip" title="{$user.username}" /></li>
                </xen:foreach>
Modify as appropriate.