We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 37286
    • 160 Posts
    That's what's so aggravating, as you can see from my previous post, loginResourceId is not set in my snippet call.
      • 3749
      • 24,544 Posts
      Make sure it's not set on the Properties tab of the snippet or in an attached Property Set.

      If that's not it, removing that property from the Properties tab of the snippet might do it. What happens sometimes is that developers test their extras before adding the properties to the Properties tab. Once the property exists on the Properties tab, isset() always comes back true for it, whether it's in the tag or not.


      ------------------------------------------------------------------------------------------
      PLEASE, PLEASE specify the version of MODX you are using.
      MODX info for everyone: http://bobsguides.com/modx.html
        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
        • 37286
        • 160 Posts
        Nothing in the properties of the chunk. In the properties of the snippet there is a loginResourceId with a value of "0". I removed that value and tried login process to see what would happen and I get the same result. When I login the page returns to the login page and displays the logout template instead of forwarding me back to the referring page.
          • 3749
          • 24,544 Posts
          Try removing the property altogether from the Properties tab (right-click on it) and saving the snippet.

          ------------------------------------------------------------------------------------------
          PLEASE, PLEASE specify the version of MODX you are using.
          MODX info for everyone: http://bobsguides.com/modx.html
            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
            • 37286
            • 160 Posts
            No luck.
              • 3749
              • 24,544 Posts
              It's starting to sound like a bug. wink


              ------------------------------------------------------------------------------------------
              PLEASE, PLEASE specify the version of MODX you are using.
              MODX info for everyone: http://bobsguides.com/modx.html
                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
                • 3749
                • 24,544 Posts
                Quote from: insomnix at Aug 24, 2012, 04:31 AM
                While not the solution I was hoping for, I did find a way to get redirectToPrior to work. In the Login.php file, approx line 329, is:
                $loginResourceId = $this->getProperty('loginResourceId',$redirectBack); 
                I commented out this line and everything works the way I want.

                I'm sure there is probably a better solution out there but I've already spent to much time on this little headache. If anyone else happens upon the better solutions, please let me know.

                I think the correct fix is to set that line to this:

                $loginResourceId = $this->getProperty('loginResourceId',$redirectBack, '!empty'); 



                  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
                  • 38783
                  • 571 Posts
                  I have just discovered that there is an error in the documentation for this. If you set &redirectToPrior to zero it will Redirect to Prior. Not what you would expect, but useful to know.

                  This does not redirect to the previous page
                  &redirectToPrior=`1`


                  This does redirect to the previous page
                  &redirectToPrior=`0`
                    If I help you out on these forums I would be very grateful if you would consider rating me on Trustpilot: https://uk.trustpilot.com/review/andytough.com

                    email: [email protected] | website: https://andytough.com
                    • 3749
                    • 24,544 Posts
                    Andy, looking at the Login code (which always gives me a headache wink ) I don't see how that's possible.

                     $redirectToPrior = $this->getProperty('redirectToPrior',false,'isset');
                    // ...
                    if (!$redirectToPrior) {
                                $phs['request_uri'] = str_replace(array('?service='.$logoutKey,'&service='.$logoutKey,'&service='.$logoutKey),'',$_SERVER['REQUEST_URI']);
                            } else {
                                $phs['request_uri'] = str_replace(array('?service='.$logoutKey,'&service='.$logoutKey,'&service='.$logoutKey),'',$_SERVER['HTTP_REFERER']);
                            }
                    
                    


                    I tested the getProperty() function using the arguments above and it definitely returns 1 and 0 as it should.
                      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
                      • 38783
                      • 571 Posts
                      I have checked the code I am using and it seems to bear out my observation. Perhaps I am doing something else wrong that is causing this.

                      When people use a link in an email to visit a restricted page they are redirected to a login page, unless they are already logged in.

                      The code for my Login page is
                      [[!Login? &loginTpl=`lgnLoginTpl` &logoutTpl=`lgnLogoutTpl` &redirectToPrior=`0` &logoutResourceId=`8` &errTpl=`lgnErrTpl`]]
                      <a href="[[~5]]">Forgot your Password?</a>
                      


                      With this code, after logging in they are redirected to the original url they tried to visit.

                      If I change the code to &redirectToPrior=`1` they end up back on the login page after logging in.
                        If I help you out on these forums I would be very grateful if you would consider rating me on Trustpilot: https://uk.trustpilot.com/review/andytough.com

                        email: [email protected] | website: https://andytough.com