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

Member and Guest Conditionals

Discussion in 'XenForo Questions and Support' started by Michael, Oct 7, 2010.

  1. Michael

    Michael Active Member

    I need to know how to show x info to members and x info to guests, anyone know the conditionals needed? I also need a conditional like the this script ones in vbulletin if anyone would like to share one for the index that would great.

    Thanks :)
     
  2. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Here is the member / guest condition:

    Code:
    <xen:if is="{$visitor.user_id}">
        FOR LOGGED IN USERS
    <xen:else />
        FOR GUESTS
    </xen:if>
    
    I do not believe there is anything like THIS_SCRIPT in xF. I could be wrong. Maybe some one else knows.
     
    CallieJo, projectego and Michael like this.
  3. Lawrence

    Lawrence Well-Known Member

    That's correct, Jake.
     
    Michael likes this.
  4. MrBrian

    MrBrian Active Member

    Not yet tested. But no harm giving it a try ;)


    For the admins ;

    Code:
    <xen:if is="{$visitor.is_admin}">
    FOR ADMINS
    </xen:if>
    
    edit: The admins conditional should work just fine.
     
    CallieJo and Michael like this.
  5. Michael

    Michael Active Member

    Thanks guys, do any you lot know the guest conditional something like so:
    Code:
    <xen:if is="{$visitor.is_guest}">
    Guests Only
    </xen:if>
    Just so I dont need to use the else constantly :D
     
  6. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    This:

    Code:
    <xen:if is="!{$visitor.user_id}">
        FOR GUESTS
    </xen:if>
    
     
    Michael likes this.
  7. Michael

    Michael Active Member

    Thanks Jake, do you know of one for under X posts show X info? :D
     
  8. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    This:

    Code:
    <xen:if is="{$visitor.message_count} < 5">
        YOU HAVE UNDER 5 POSTS
    </xen:if>
    
     
    Michael likes this.
  9. Michael

    Michael Active Member

    Awesome thank you, looks like I have almost all the conditionals I will need for a while now :D
     
  10. Shanj

    Shanj Well-Known Member

    What about for multiple usergroups 1, 2,3 ?
    Thanks
     
  11. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    I can't find a way to check secondary groups with a template conditional. I looked through the template functions but I don't see anything for this purpose.

    Maybe some one else knows.
     
  12. Shanj

    Shanj Well-Known Member


    Nah what I meant was to allow access to 2 or 3 different usergroups using their usergroup number. Rather than coding 3 different chunks of cose - or 30 different chunks!
     
  13. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    If they are all primary groups then you can do this:

    Code:
    <xen:if is="{$visitor.user_group_id} == X OR {$visitor.user_group_id} == Y OR {$visitor.user_group_id} == Z">
        STUFF FOR GROUPS X,Y,Z
    </xen:if>
    
    But this doesn't check secondary groups.

    This code could be shortened with array functions, but those don't appear to work here. I am still learning the system.
     
  14. Shanj

    Shanj Well-Known Member

    Thanks lots. I never got the hang of secondary groups anyway - they seem to dominate too much. So all mine are primary.
     

Share This Page