We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 40122
    • 330 Posts
    I am using Login.Login to register and login memebers and it works great.

    However, I need to make a way of redirecting visitors to a Register page if the try to access a members only page.

    In the documentation for Login.Login it mentions the property:

    redirectToOnFailedAuth


    But I have no idea how to use it, and I dont think it is what I want.

    Can anyone point me in the right direction?

    Thanks!
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      Create a resource for unauthorized users. In the System Settings, set the unauthorized_page setting to the ID of your resource.
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 40122
        • 330 Posts
        Quote from: sottwell at May 09, 2014, 01:31 AM
        Create a resource for unauthorized users. In the System Settings, set the unauthorized_page setting to the ID of your resource.

        Thanks Sottwell,

        That makes sense, however it still redirects to my error_page.

        Any other suggestions?
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          The (anonymous) group has to have load permission for your resources. If they can't load the protected resources they can't even see that they exist, thus getting the error_page.
            Studying MODX in the desert - http://sottwell.com
            Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
            Join the Slack Community - http://modx.org
            • 40122
            • 330 Posts
            Quote from: sottwell at May 09, 2014, 08:59 PM
            The (anonymous) group has to have load permission for your resources. If they can't load the protected resources they can't even see that they exist, thus getting the error_page.

            Thanks Sottwell, but still no luck.

            I have set it up as such:



            But it still 404s. Its a really odd problem...would you know if I have done something wrong?
              • 28042 ☆ A M B ☆
              • 24,524 Posts
              Are you sure that your unauthorized page is published, and not protected?
                Studying MODX in the desert - http://sottwell.com
                Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                Join the Slack Community - http://modx.org
                • 40122
                • 330 Posts
                Quote from: sottwell at May 10, 2014, 01:43 AM
                Are you sure that your unauthorized page is published, and not protected?

                Yes it is published and not part of a Resource Group
                  • 28042 ☆ A M B ☆
                  • 24,524 Posts
                  Sorry, that's my full $.02 worth. Hopefully somebody else will have a better idea.
                    Studying MODX in the desert - http://sottwell.com
                    Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                    Join the Slack Community - http://modx.org
                    • 40122
                    • 330 Posts
                    Quote from: sottwell at May 10, 2014, 11:38 PM
                    Sorry, that's my full $.02 worth. Hopefully somebody else will have a better idea.

                    No Problem! Thanks sottwell!
                      • 3749
                      • 24,544 Posts
                      You might try Load, List, and View.

                      That said, I think I would use a snippet in the Template, something like this:

                      $registerId=`12';  /* ID of registration page */
                      
                      $url = $modx->makeUrl($registerId, "", "", "full");
                      
                      if (! $modx->user->isMember('someGroup')) {
                        $modx->sendRedirect($url);
                      }
                      return '';
                      



                      You could speed this up slightly by hard-coding the URL of the registration page in the sendRedirect() and removing the first two lines.
                        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