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

XF 1.2 Not show something to hidden users

Discussion in 'XenForo Questions and Support' started by Martok, Aug 14, 2013.

  1. Martok

    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


    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.
    snoopy5 likes this.
  2. Jeremy

    Jeremy XenForo Moderator Staff Member

    Are you trying to show it if any of those three are valid and they are invisible? Try:
    <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
    Note: That code is untested.
  3. Martok

    Martok Well-Known Member

    No, I'm trying to show it to any of the 3 that are valid and they are visible.

    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.
  4. Jeremy

    Jeremy XenForo Moderator Staff Member

    You want it to show when visible (Guess I misread that)? Remove the ! from {$user.visible}.
  5. Martok

    Martok Well-Known Member

    I've just tried that and the content was not visible to anyone!

    I even tried reducing it to just one group:

    <xen:if is="{xen:helper ismemberof, $visitor, 7} AND {$user.visible}">
    This content will show only those listed
    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.

  6. Brogan

    Brogan XenForo Moderator Staff Member

    Use $visitor.visible
    Jeremy likes this.
  7. Martok

    Martok Well-Known Member

    Thank you, both of you! It now works perfectly! :D
  8. Jeremy

    Jeremy XenForo Moderator Staff Member

    Paul to the rescue. (y) Not sure why that didn't occur to me.

Share This Page