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

User Group specific conditional

Discussion in 'XenForo Questions and Support' started by hathway, May 24, 2012.

  1. hathway

    hathway Member

    I am trying to display different content depending on what user group the user (not visitor) is a member of.

    I came up with this:

    <xen:if is="{xen:helper ismemberof, $user, 3}">
    <p class="userGroupTitle">Administrator</p>
    </xen:if>
    <xen:if is="{xen:helper ismemberof, $user, 4}">
    <p class="userGroupTitle">Moderator</p>
    </xen:if>
    <xen:if is="{xen:helper ismemberof, $user, 10}">
    <p class="userGroupTitle">10</p>
    </xen:if>
    <xen:if is="{xen:helper ismemberof, $user, 11}">
    <p class="userGroupTitle">11</p>
    </xen:if>

    and noticed it would not work for the Moderator or Administrator user groups. So I checked the user permissions and found it is due to the moderators and administrators not being added to the usergroups in question on their personal user permission page, yet through the moderator and administrator pages. I thought this was the correct way of doing it? Is this a bug?
     
  2. hathway

    hathway Member

    For now I am using this to get around it:

    <xen:if is="{$user.is_admin}">
    <p class="userGroupTitle">Administrator</p>
    </xen:if>
    <xen:if is="{$user.is_moderator}">
    <p class="userGroupTitle">Moderator</p>
    </xen:if>
    <xen:if is="{xen:helper ismemberof, $user, 10}">
    <p class="userGroupTitle">10</p>
    </xen:if>
    <xen:if is="{xen:helper ismemberof, $user, 11}">
    <p class="userGroupTitle">11</p>
    </xen:if>

    But I would like to know if this is a bug or am I setting up my mod and admin's permissions incorrectly?
     
  3. hathway

    hathway Member

    I am not using 'if elseif else' conditionals because some users are members to multiple groups.
     
  4. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Not a bug. Admins and mods don't have to belong to the admin / mod groups. You can choose how to setup your admins and mods.
     
  5. hathway

    hathway Member

    Maybe I am not explaining it well enough, if I check to add moderators or administrators through the mod or admin ACP pages, (/admin.php?moderators/super/admin.1/edit), it will not recognize they are a member of that usergroup with the {xen:helper ismemberof, $user, 4}.

    It will only recognize them as being a member if I check them as part of that group on their own user page (/admin.php?users/admin.1/edit). That does not sound right to me, but I wanted to bring it up here.
     
  6. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    That's correct. Mod permissions can be granted without a usergroup. That is working as designed.

    For your purposes you should also add them to the mod group since you want conditions based on group.
     
  7. hathway

    hathway Member

    I think you are misunderstanding me lol, they ARE members of the user groups in question. I added them through the moderator or administrator page though, not their own personal page. Here is what I mean: admin.jpg

    So even though they are members of those user groups, they are not recognized through {xen:helper ismemberof, $user, 3}.
     
  8. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    That user must have been removed from the group at some point. You can edit their profile (left part of screenshot) and add them again. Or edit the admin record (right part of screenshot) to add them again. Submitting either form will update their groups.
     

Share This Page