We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 8168
    • 1,118 Posts
    Hi, I am using Login addon in my site, I have a login page which is ID 28, what I would like is a snippet to add to this page to redirect users who are logged in already when they land on this page to be redirected to page ID 29. So they don't see the login page if they happen to navigate back to it - ID 29 is the Members homepage, Is this possible? So I want anyone who is not logged in to stay on page ID 28 when they visit it, but if the user is already logged in and they land on page ID 28 to be redirected to page ID 29.



    This question has been answered by vigilante. See the first response.

    • discuss.answer
      • 38850
      • 110 Posts
      The login snippet already detects if they are logged in and if they are it will show a logout link instead of the login form.

      If you really need to test and redirect, you might have a snippet like this:

      if ($modx->user->hasSessionContext($modx->context->get('key'))) {
          $url = $modx->makeUrl(29);

      Read about the sendRedirect function and options here:
        • 8168
        • 1,118 Posts
        Thanks vigillante - works a dream!