We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 19740
    • 12 Posts
    Hi
    First thing I LOVE MODX. It is awesome. Thankyou for making it and making it goooood. smiley

    Next, I was wondering if it is possible to hide a register button in modx once a user is logged in. I currently have the button in my navigation but would like to have it hidden when user is logged in. Is this possible, hope it is. Something like the Login/Logout button that changes when logged in.

    I am using modx 0.9.5

    Many thanks

    Milo
      • 1511
      • 144 Posts
      Check the snippets "CheckMember" and "Personalize". They are included in the default install.

      "Personalize" will check if the user is logged in and display the appropriate chunk.
      "MemberCheck" will display a defined chunk if the user is a member of specified Webuser group.
        • 19740
        • 12 Posts
        Hi
        That looks like it will work but I am not sure how you would go about putting this in the page title :/.

        Any tips?

        Thanks
        Milo
          • 7455
          • 2,204 Posts
          you can use chunks snippets and tv in you pagetitle field. it acts the same as you contentfield so you could place a [*login*] there and place a pice of php in there with the @EVAL binding that check if a user is logge din if so it returs logout els it returns login.
          if you install modx including the sample site then this is used there also
            follow me on twitter: @dimmy01
            • 1511
            • 144 Posts
            Well, the response (one of them wink ) is a template variable. Check the already included sample, the TV called "loginName".

            It’s a text input TV, with the default value of:
            @EVAL if ($modx->getLoginUserID()) return 'Logout'; else return 'Login';

            From this you can work out your code and save it as another TV, let’s say nameOfTV.
            You can use any php function/code/modx functionality to get the info you want.

            Later, your page title would be [*nameOfTV*] and the title would change dinamically.

            MODx 0.9.5 has a bug and the EVAL code in the TV must all be in one line!
            If you need more code rather use a snippet call in the TV. See http://modxcms.com/forums/index.php/topic,11315.0.html
              • 19740
              • 12 Posts
              Thanks for the quick replies.

              I already have that Login/Logout function but was wondering if I could have the register button only show when not logged in becuase I want to make the site easy to use. The above example looks like it will still show the button :/ Not sure.

              Thanks, your help is greatly appreciated
              Milo
                • 19740
                • 12 Posts
                Anyone? Please.... huh
                  • 1511
                  • 144 Posts
                  Use snippet Personalize.

                  # Snippet Name: Personalize
                  # Short Desc: calls a chunk if the user is logged in, otherwise calls another
                  #::::::::::::::::::::::::::::::::::::::::
                  # Description:
                  # Checks to see if webusers are logged in and displays yesChunk if the user
                  # is logged or noChunk if user is not logged. Insert only the chunk name as
                  # param, without {{}}. Can use a placeholder to output the username.
                  # TESTED: can be used more than once per page.
                  # TESTED: chunks can contain snippets.

                  Leave &yesChunk empty and put the button code in the &noChunk.
                    • 19740
                    • 12 Posts
                    Hi
                    I have tried using the chunk but it does not return what is in the chunkand does not show anything. Any tips?

                    Thanks
                    Milo
                      • 25663 MODX Staff
                      • 12,272 Posts
                      mithi, please show us how you’re calling the Personalize snippet ... I suspect cached, which won’t work:

                      [[Cached]]

                      [!Uncached!]
                        Ryan Thrash, MODX Co-Founder
                        Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me