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

Help with showing content to certain usergroups

gldtn

Well-known member
#1
Hello guys, I'm trying to show a certain piece of code using this:

Code:
<xen:if is="{xen:helper ismemberof, $user, x} AND {$user.is_admin} OR {$user.is_moderator}">

CODE HERE

</xen:if>
But I get:
emplate Errors: PAGE_CONTAINER

  1. Argument 1 passed to XenForo_Template_Helper_Core::helperIsMemberOf() must be an array, null givenin /home/user/public_html/forumdir/library/XenForo/Template/Helper/Core.php, line 1028:
    1027: } 1028: $__compilerVar41 .= ' 1029: </span>
  2. Argument 1 passed to XenForo_Model_User::isMemberOfUserGroup() must be an array, null given, called in /home/user/public_html/forumdir/library/XenForo/Template/Helper/Core.php on line 1030 and definedin /home/user/public_html/forumdir/library/XenForo/Model/User.php, line 1308:
    1307: </div> 1308: <ul class="secondaryContent blockLinksList"> 1309: ';


Any ideas?
 

Jake Bunce

XenForo moderator
Staff member
#2
Which template? Apparently $user isn't available.

If you want to check the current logged in user then use $visitor.
 

gldtn

Well-known member
#5
That worked, but
{xen:helper ismemberof, $visitor, x}

X usergroupd is not seeing what is suppose to display!

Only admins and moderators
 

Jake Bunce

XenForo moderator
Staff member
#6
Change your condition to this:

Code:
<xen:if is="{xen:helper ismemberof, $visitor, x} OR {$visitor.is_admin} OR {$visitor.is_moderator}">

</xen:if>
You were using AND which is not correct for what you want.
 

giorgino

Well-known member
#8
Hi Jake, in your opinion, why this conditional don't work? :(

Code:
<xen:if is="{xen:helper ismemberof, $user, 39}">
    <span style="padding-left:5px;"><img src="styles/immobilio/rank/01.png"></span>
<xen:elseif is="{xen:helper ismemberof, $user, 40}" />
    <span style="padding-left:5px;"><img src="styles/immobilio/rank/02.png"></span>
<xen:elseif is="{xen:helper ismemberof, $user, 36}" />
    <span style="padding-left:5px;"><img src="styles/immobilio/rank/03.png"></span>
<xen:elseif is="{xen:helper ismemberof, $user, 35}" />
    <span style="padding-left:5px;"><img src="styles/immobilio/rank/04.png"></span>
<xen:elseif is="{xen:helper ismemberof, $user, 41}" />
    <span style="padding-left:5px;"><img src="styles/immobilio/rank/05.png"></span>
<xen:elseif is="{xen:helper ismemberof, $user, 42}" />
    <span style="padding-left:5px;"><img src="styles/immobilio/rank/06.png"></span>
<xen:else />
    <span style="padding-left:5px;"><img src="styles/immobilio/rank/00.png"></span>
</xen:if>
 

Jake Bunce

XenForo moderator
Staff member
#9
Hi Jake, in your opinion, why this conditional don't work? :(
In what template?

That code looks to be showing different images based on usergroup. The elseif's mean it will only ever show one image regardless of how many ranks the user qualifies for.
 

giorgino

Well-known member
#10
That code looks to be showing different images based on usergroup
Exactly.
The code is inserted in message_user_info and show a different progress bar based on user group.

My idea was a case-of logic structure and not a mere if-then, but I don't found switch or case in xenforo syntax...
How can I do?

Thanks :)
 

Jake Bunce

XenForo moderator
Staff member
#11
Did you intend to show multiple images for individual users? Try this:

Code:
<xen:if is="{xen:helper ismemberof, $user, 39}">
    <span style="padding-left:5px;"><img src="styles/immobilio/rank/01.png"></span>
</xen:if>

<xen:if is="{xen:helper ismemberof, $user, 40}">
    <span style="padding-left:5px;"><img src="styles/immobilio/rank/02.png"></span>
</xen:if>

<xen:if is="{xen:helper ismemberof, $user, 36}">
    <span style="padding-left:5px;"><img src="styles/immobilio/rank/03.png"></span>
</xen:if>

<xen:if is="{xen:helper ismemberof, $user, 35}">
    <span style="padding-left:5px;"><img src="styles/immobilio/rank/04.png"></span>
</xen:if>

<xen:if is="{xen:helper ismemberof, $user, 41}">
    <span style="padding-left:5px;"><img src="styles/immobilio/rank/05.png"></span>
</xen:if>

<xen:if is="{xen:helper ismemberof, $user, 42}">
    <span style="padding-left:5px;"><img src="styles/immobilio/rank/06.png"></span>
</xen:if>
 

giorgino

Well-known member
#12
No Jack, I need to display one badge for each specific user group.

I can do this with a series of if like you've suggested.

My intention is to find a logic structure more sophisticated like a case in php language for instance.