1. 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

Discussion in 'XenForo Development Discussions' started by Zephyr, Sep 28, 2012.

  1. Zephyr

    Zephyr Well-Known Member

    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 :)
     
  2. Chris D

    Chris D XenForo Developer Staff Member

    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>
     
    Jake Bunce and Zephyr like this.
  3. Zephyr

    Zephyr Well-Known Member

    Thank :)
     
    Chris D likes this.
  4. Zephyr

    Zephyr Well-Known Member

    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

    [​IMG]

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

    Russ Well-Known Member

    Jake Bunce likes this.
  6. Zephyr

    Zephyr Well-Known Member

  7. Russ

    Russ Well-Known Member

    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
     
    Jake Bunce and Zephyr like this.
  8. Zephyr

    Zephyr Well-Known Member

    Thank you very much, everything works perfectly! :)
     

Share This Page