XF 1.2 Not show something to hidden users

Martok

Well-known member
I'm looking to hide some content from hidden users and I could do with a little help with this.

The content will be visible to a certain usergroup, admins and moderators. Guests won't see it and I don't want hidden users to see it either (even if they are in the groups that can see the resource).

The code I have so far is:

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

This content will show only those listed

</xen:if>


I'm aware of the {xen:if '!{$user.visible}', ' invisible'} but I'm not sure it will work in here? I'm thinking I'll need an AND somewhere but I'm not sure how to fit this all together.
 
Are you trying to show it if any of those three are valid and they are invisible? Try:
Code:
<xen:if is="({xen:helper ismemberof, $visitor, 7} OR {$visitor.is_admin} OR {$visitor.is_moderator}) AND !{$user.visible}">

This content will show only those listed

</xen:if>

Note: That code is untested.
 
Are you trying to show it if any of those three are valid and they are invisible?
No, I'm trying to show it to any of the 3 that are valid and they are visible.


Try:
Code:
<xen:if is="({xen:helper ismemberof, $visitor, 7} OR {$visitor.is_admin} OR {$visitor.is_moderator}) AND !{$user.visible}">

This content will show only those listed

</xen:if>
Note: That code is untested.

I nearly had the same code as you though I forgot the rounded brackets around the first part.

Unfortunately the code doesn't work. Tried it with two of the groups whilst a hidden user and they could still see the content.
 
I've just tried that and the content was not visible to anyone!

I even tried reducing it to just one group:

Code:
<xen:if is="{xen:helper ismemberof, $visitor, 7} AND {$user.visible}">

This content will show only those listed

</xen:if>

but it still didn't work, the content was hidden to that group as well as everyone else.

Maybe there's an issue with {$user.visible}? Don't we need to state that this variable should have a value of 'visible' (or 'invisible')? Maybe this variable can't be used in this context? I know it's generally used with styling usernames.

http://xenforo.com/community/resources/sidebar-user-name-styling.1737/
 
Back
Top Bottom