We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 36524
    • 8 Posts
    This works, sorta. It pulls the users when logged in and shows the logout link. Perfect! But when the user is not logged in it just shows Welcome Logout. It seems to be skipping the conditional &Then.

    It dawned on me that maybe the (anon) user was set to be logged in, but no joy. I have three sets of users, Admin, Member, and the Anon. So that is not it.

    The strange thing about it is that I have a similar login in the side bar of the home page and it works perfect. The only difference is that it is based on TV's and chunks that swap if the users is logged in or not.


    [[!Profile? &prefix=`modx.user.`]]
    [[!If?
       &subject=`[[+modx.user.id]]`
       &operator=`EQ`
       &operand=`0`
       &then=`<span id="welcome">Not logged in.</span> <a href="[[~5]]">Login</a> <span id="welcome">Or Register</span> <a href="[[~115]]">Register</a>`
       &else=`<span id="welcome">Welcome [[+modx.user.firstname]]<span> <a href="[[~1? &service=`logout`]]" title="Logout">Logout</a>`
    ]]
    
      • 22303 MODX Staff
      • 10,725 Posts
      Check the cache file, but I believe the placeholders nested in your If call need to be called non-cacheable so they are not cached into the cacheable content the first time.
        • 36524
        • 8 Posts
        So am I thinking correctly when i add ! to these placeholders? I have tried it but it seems to be doing the same thing.

         [[!+modx.user.id]] , [[!+modx.user.firstname]] 


        I also tried just calling the chunk non cached and it is not working. like such
        [[!$logoutStandard?]]
        , no joy. [ed. note: demena last edited this post 15 years, 2 months ago.]
          • 22303 MODX Staff
          • 10,725 Posts
          What version of Revolution are you using?
            • 36524
            • 8 Posts
            2.1.1 pl thanks for helping out.
              • 3749
              • 24,544 Posts
              Are you previewing from the Manager? That could be giving you the wrong user ID.
                Did I help you? Buy me a beer
                Get my Book: MODX:The Official Guide
                MODX info for everyone: http://bobsguides.com/modx.html
                My MODX Extras
                Bob's Guides is now hosted at A2 MODX Hosting
                • 36524
                • 8 Posts
                I am not previewing from the manager. I am however developing on Mamp pro, but that shouldn't matter I have mirrored the live server settings, and everything else using the login is working fine.

                here is what it is doing.

                if not logged in it says:

                Welcome Logout and logout is a link to &service=`logout` unfortunately you are not logged in though.

                This should be the &then statement:
                Not Logged in. Login Or Register <---this I notice I am repeating twice so I am just going to nest the link in the Or Register.

                If you are logged in you get:

                Wlecome Username Logout This is correct and the logout works properly.

                The only thing that is not working is the hook to the &then statement.

                Thanks again to both of you.
                  • 36524
                  • 8 Posts
                  Okay I flipped it around and it worked. I am not sure why but doesn't matter really. Here is the code:
                  [[!Profile?]]
                  [[!If?
                     &subject=`[[+id]]`
                     &operator=`EQ`
                     &operand=`1`
                     &else=`<span id="welcome">Not logged in.<a href="[[~5]]"> Login</a>, Or <a href="[[~115]]">Register</a></span>`
                     &then=`<span id="welcome">Welcome [[!+firstname]]<span> <a href="[[~1? &service=`logout`]]" title="Logout">Logout</a>`
                  ]]
                    • 36524
                    • 8 Posts
                    Solved.