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

Member and Guest Conditionals

Michael

Active member
#1
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
#2
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.
 

Michael

Active member
#5
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
#11
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
#12
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
#13
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
#14
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.