We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 34120
    • 236 Posts
    Hi, thanks for the reply, I think this was probably the problem. I've got it working now although I'm not 100% clear on how. Here's what I'm doing.

    I'm using
    [[!isLoggedIn]]
    on my protected resource. If a user isn't logged in this will redirect them to unauthorized_page (configured as my login screen). To get this to work I had to uncheck the access permissions removing the resource from the Resource Group I had created. That's the bit I don't really understand.
      • 3749
      • 24,544 Posts
      I had to uncheck the access permissions removing the resource from the Resource Group I had created

      I'm not sure exactly what that means (since there are no access permissions that remove a resource from resource group), but if the page is protected and the user has no rights to it, they get forwarded to the error page before your snippet could execute.

      If you use a snippet like that, you may not need any resource groups. One side effect, though, is that add-on components like Wayfinder and getResources will not respect your snippet. Wayfinder will show it in menus and getResources will show its content in aggregations.
        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
        • 34120
        • 236 Posts
        Thanks Bob, I've attached a screen grab rather than attempting to explain. I need to do some more testing to figure this out and I'll checkout the potential issues you suggested.
          • 36538
          • 4 Posts
          Hi everybody, there is an ambigious thing in the name of the snippet isLoggedIn.
          In fact this snippet doing something only if you are Not logged in.
          A redirection to the page you want. So you should call it isNotLoggedIn.
          I tought i could use this snippet to redirect allready logged-in users to their own pages. Specialy in the login page wich in my case is useless when allredy login and wich is my start page.
          So i hacked isLoggedIn to use it has well. At the fourth line :
          if (!$modx->user->hasSessionContext($ctxs)) {

          Without exclamation mark like this :
          if ($modx->user->hasSessionContext($ctxs)) {

            • 40553
            • 42 Posts
            Quote from: BobRay at Nov 30, 2010, 10:55 PM
            You're right about the process. If the user isn't authorized to load a page, the page doesn't exist and the user is forwarded to the error_page. One solution is to give anonymous users the load permission in the web context. Then the page should load and the snippet should run.

            There's more info on this here: http://bobsguides.com/revolution-permissions.html (near the bottom of the page).

            But the anonymous user group has the context access policy of laod only by default so I'm not getting it?
              • 3749
              • 24,544 Posts
              They do now. That wasn't always a default setting. You might have to make it "Load, List, and View" to avoid the error Page.
                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