Member and Guest Conditionals

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 :)
 

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.
 

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.
 

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
 

Jake Bunce

XenForo moderator
Staff 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
This:

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

Michael

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

Jake Bunce

XenForo moderator
Staff member
What about for multiple usergroups 1, 2,3 ?
Thanks
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.
 

Shanj

Well-known 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.

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!
 

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.
 

Shanj

Well-known 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.
Thanks lots. I never got the hang of secondary groups anyway - they seem to dominate too much. So all mine are primary.
 
Top