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

Condition - If user is not connected

Zephyr

Well-known member
#1
Hello, I would like to know how to check if a user is logged or not please :)

Code:
<xen:if is="{$visitor.???????????}">
    // Here is my code for visitors
</xen:if>
Thank :)
 

Chris D

XenForo developer
Staff member
#2
Hello, I would like to know how to check if a user is logged or not please :)

Code:
<xen:if is="{$visitor.???????????}">
    // Here is my code for visitors
</xen:if>
Thank :)
If users are logged in they will have a user_id so...

<xen:if is="{$visitor.user_id}">
// Code for registered users
</xen:if>

You could also do:

<xen:if is="{$visitor.user_id}">
// Code for registered users
<xen:else />
// Code for guests
</xen:if>

Or you could even do:

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

Zephyr

Well-known member
#4
I have :

Code:
<xen:if is="!{$visitor.user_id}">
    #loginBar .pageContent
    {
        padding-top: 0px !important;
    }
    #moderatorBar
    {
        border-bottom: none !important;
    }
</xen:if>
Border bottom is not displayed (for user registered) :S



<xen:if is="{$visitor.user_id}">
// This code loads the css for everyone :/
</xen:if>
 

Russ

Well-known member
#7
Hmm few things:
<!- this is a comment --> with the !


Also that's putting it as a regular text, easy way could be this:

Rename that template to: XenCrea_CustomGuest (remove the .css)

Then inside the XenCrea_CustomGuest wrap all the css in this:

Code:
<style type="text/css">
 
 
</style>
And in your conditional remove the .css too