User Group specific conditional

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?
 
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?
 
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.
 
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.
 
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.webp

So even though they are members of those user groups, they are not recognized through {xen:helper ismemberof, $user, 3}.
 
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.
 
Top Bottom