On March 26, 2019 we launched new MODX Forums. Please join us at the new MODX Community Forums.
Subscribe: RSS
  • Hi,

    I'm having the following issue:

    I want to redirect to a specific resource (in my case with ID 3) if the user failed to login.
    I'm using the following call:

    [[!Login? &preHooks=`preHook.DiscussLogin` &loginResourceId=`20` &loginTpl=`lgnNewFrontTpl` &postHooks=`postHook.DiscussLogin` &redirectToOnFailedAuth=`3` ]]


    but nothing happens.

    The lgnNewFrontTpl call is the following (if it matters):
    <div class="loginForm">
        <div class="loginMessage">[[+errors]]</div>
        <div class="loginFront">
            <form class="loginLoginForm" action="[[~[[*id]]]]" method="post">
                <fieldset>
                    <p><a href="[[~6]]">Sign Up</a><a href="[[~11]]">Forgot your password?</a></p>
                    <p><input type="text" name="username" id="login-username" placeholder="username"></p>
                    <p><input type="password" name="password" id="login-password" placeholder="password"></p>
                    <input class="returnUrl" type="hidden" name="returnUrl" value="[[+request_uri]]" />
                    [[+login.recaptcha_html]]
                    <input class="loginLoginValue" type="hidden" name="service" value="login" />
                    <span class="loginLoginButton"><input type="submit" name="Login" value="[[+actionMsg]]"  /></span>
                </fieldset>
            </form>
        </div>
    </div>


    I think I'm doing something wrong with the &redirectToOnFailedAuth=`3`. There is no info how to use it.
    In the Login documentation (http://rtfm.modx.com/extras/revo/login/login.login) is written the following:
    redirectToOnFailedAuth (1.6.4-pl & +) redirects to a separate page on failed logins

    Did somebody know how to use the &redirectToOnFailedAuth or if there is another way to make this redirection working?

    Thank you in advance!
      peace&love / bike&ride
    • Have you tried creating a property set for the login snippet, and setting the redirectToOnFailedAuth property there?

      To do this, go to the snippet>properties tab>add property set> then edit your desired properties (don't forget the redirect property).

      Adding a property set will prevent the default locked properties from being overwritten when upgrading your plugin.
      • Another way to go is to just add that property to the Login snippet tag. It will survive upgrades there too:

        [[!Login? &redirectToOnFailedAuth=`12`]]



        (Replace 12 with the ID of the page you want to send them to.)
          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
        • Thank you both for the answers!

          @BobRay: I've added already that property to my Login snippet tag. You can see it at the end of the Login call above.

          @brandonhim: I have to check later in the day if this is going to work and will post the result here.
            peace&love / bike&ride
          • So, none of the above posted solutions is working for me.

            We found another way to make this happen and it's with using the code from the Discuss login (it's installed also on the site). In the Forum (Discuss) when you enter wrong user or password and login failed it redirects you to the login page.

            So just changed line 4 in lgnNewFrintTpl (which is edited lgnLoginTpl chunk) with this :
            <form class="loginLoginForm" method="post" action="[[~[[++discuss.login_resource_id]]]]">


            In this case you don't need &redirectToOnFailedAuth in your Login snippet tag.
            But still wondering why it's not working the standard way with using &redirectToOnFailedAuth.
              peace&love / bike&ride
            • Quote from: deyand at Mar 16, 2015, 06:40 PM
              But still wondering why it's not working the standard way with using &redirectToOnFailedAuth.

              i'm with ya! i just discovered using "&redirectToOnFailedAuth=`#`" in my login does NOT work either!
              and neither does "&redirectToPrior=`#`".

              i've searched & read as much as i could find on these 2, but they just simply do not work (for me) on Revo 2.4.3.

              any errors in the login that would redirect to another Resource, would always go to my 404 Page Not Found page/resource i have set in the System Settings.

              FYI: i'm not necessarily needing a reply; i've done workarounds or alternative methods to accomplish what i need; just piping in to express my agreement of there being a problem.

              • @SyberKnight -- both of those properties take a Resource ID for their arguments.

                Also, &redirectToOnFailedAuth can't be used to redirect to the current page.

                if ($redirectToOnFailedAuth && $redirectToOnFailedAuth != $this->modx->resource->get('id')) {


                The page you redirect to needs to be published and accessible by anonymous users. It probably also needs to be in the main front-end context ('web').
                  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
                • Quote from: BobRay at May 18, 2016, 11:11 PM
                  @SyberKnight -- both of those properties take a Resource ID for their arguments.
                  Also, &redirectToOnFailedAuth can't be used to redirect to the current page.
                  The page you redirect to needs to be published and accessible by anonymous users. It probably also needs to be in the main front-end context ('web').

                  Hi Bob,

                  thanks for piping in, but these are things i actually DO know (LOL - as opposed to the many many i don't).

                  i only wrote the above with pound/hash/number symbol instead of the numbers i use because everyone has different numbers. i do have the proper numbers in there for my resource id's.

                  also note, i'm not trying to redirect to the current page. i have separate "error" pages setup with (hopefully) helpful tips on why the user may have gotten there & how to remedy the issue. and they are published & accessible & front-end'ed.

                  even still, when i test for the errors, the 404 page always overrides the redirectToOnFailedAuth page.

                  and as far as the redirectToPrior goes, it just never worked. after login, it would just redirect to the homepage. so i'm using the loginResourceId to make it redirect to the page of my choosing instead.

                  thanks tho!!!
                  • Just wondering if anyone resolved this bug as I seem to be having the same issue. I am trying to redirect failed logins to a different resource and it is not working. It is just reloading the current page.

                    I am using redirectToOnFailedAuth=`11` with the id I want failed logins to redirect to just as the others point out above.