We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
  • How can i setup resources only for anonymous clients? Example of guest-only is register and login pages which should not be loaded for logged in users. I created inverse of Login.isLoggedIn snippet to do it.

    Is it possible to do it via users/resources groups? I tried to do it by anonymous user group but no success.


    Regards, [ed. note: AHHP last edited this post 9 years, 8 months ago.]
      God loves me. 【ツ】


      MODX.ir (Persian Support)

      Boplo.ir/modx/ (Persian)
      • 3749
      • 24,544 Posts
      Adding those pages to a Resource Group and connecting that Resource Group to the anonymous user group with a Resource Group Access ACL entry with a context of 'web' (or whatever the front-end context is) should work as long as the anonymous group has no users. Note that you'd have to visit the site from another browser where you're not logged in to either the Manager or the front end to test it.

      If it really doesn't work, another alternative would be to use the Personalize snippet to show a different menu to logged-in and not-logged-in users. You could also create a plugin attached to OnHandleRequest that would forward users to another page if they were logged in. That would look something like this:

      /* Do nothing if user is not logged in */
      if (!$modx->user->hasSessionContext($modx->context->get('key'))) {
          return '';
      }
      /* Forward logged-in users to another page */
      $forwardPage = 12; /* ID of the page you want to send them to */
      $url = $modx->makeUrl($forwardPage, "", "", "full");
      $modx->sendRedirect($url);
      return;









        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
      • I rolled back my changes on users groups and created a resource group and just set name field and Automatically Give Anonymous Access option in New Resource Group dialog.
        After assigning resources to the new group. It worked for web users (manager session is considered as anonymous).
        Pages are available to all except logged in web users. That's what i needed. Thanks Bob. [ed. note: AHHP last edited this post 9 years, 8 months ago.]
          God loves me. 【ツ】


          MODX.ir (Persian Support)

          Boplo.ir/modx/ (Persian)
          • 3749
          • 24,544 Posts
          I'm glad you got it sorted. It sounds like a case where the security permissions Wizard led you astray. wink

            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