We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 23183
    • 102 Posts
    I have WebloginPE set up and pretty much all working. In the header of the document I have a link to ’login | register’ or ’logout username’ depending on if the user is logged in. I had this working the other day, but now the link changes if a ’logout’ button is pressed. But if the ’logout’ link at the top is pressed it just redirects to the succeful logout page, but doesnt actually log the user out and the ’logout’ link doesnt change to login.

    I have creates a snippet which I have them placed in the header chunk, the code is as follows:
    <?php
    # do the work
    $user = $modx->getLoginUserName();
    if ($user) {
      return '<a href="[~14~]&service=logout">Logout ' . $user . '</a>';
    } else {
       return '<a href="[~9~]">Login</a> | <a href="[~10~]">Register</a>';
    }
    ?>


    so the service ’logout’ is not getting executed when the link is clicked.. annoying as it was working yesterdya and I dont know what I have changed since.

      • 23183
      • 102 Posts
      Can anyone shed some light on why the service isn’t being carried out?

      Pretty sure its a simple reason but I cant figure it out :/
        • 10487 MODX Staff
        • 1,535 Posts
        Do you have friendly URLs enabled? If so, your link will need to be:
        [~14~]?service=logout

        Other than that, check your snippet/page caching settings to make sure that the relevant snippets are running uncached.
          Garry Nutting
          Senior Developer
          MODX, LLC

          Email: [email protected]
          Twitter: @garryn
          Web: modx.com
          • 23183
          • 102 Posts
          Thanks for the reply Gary -

          Not using friendly URLs adn all the snippets are set to Uncached.

          Could it be possible that it does not know what the service ’logout’ is meant to do? I have the above snippet called from a chunk placed on every page in the header: [!loginlogout!]. But inside that chunk there are no references to the [!WebLoginPE!]snippet do I need to add that snippet somewhere in the chunk to pick up the service ’logout’?

          Hope that makes sense!
            • 23183
            • 102 Posts
            Also is it correct that the service should appear in the address bar when the link is clicked? like

            ../index.php?id=14&service=logout
              • 27421
              • 67 Posts
              Did you find a resolution for this? I’m having the same issue.