We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 3749
    • 24,544 Posts
    Permissions can be really frustrating at times.

    The only thing I can think of is that maybe your PreMember is not logged in and is being seen as the (anonymous) user.
      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
      • 42443
      • 17 Posts
      Yes, it's not as straight forward as I would assume.

      The thing is an anonymous user can see the right page. It's those user who are registered but not yet a member who are problematic.

      Could the problem be elsewhere?

      Rob
        • 3749
        • 24,544 Posts
        The only other thing that could affect it would be a custom snippet protecting one of the pages (which BTW, might not be a bad idea for your case).

        What I would suggest is that since you have a teaser to show, don't protect the page in any way (i.e., don't put it in a resource group at all). Rather, protect the premium content by putting it in alternative chunks and showing the appropriate chunk with the Personalize snippet or a custom snippet like the following:

        Put this on the page where the content goes:

        [[!ProtectedContent]]



        Create a snippet called ProtectedContent with this code:

        /* ProtectedContent snippet */
        if ($modx->user->isMember('Members')) {
           return $modx->getChunk('ProtectedContent');
        } else {
           return $modx->getChunk('Teaser');
        }
        [ed. note: BobRay last edited this post 12 years, 6 months ago.]
          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
          • 42443
          • 17 Posts
          Thank you again Bob for sticking with this.

          This is a web site I've inherited and it looks like the issue is around the misuse of Resource Groups.

          The pages in question should only be controlled by User Groups but for some reason they've also been added to a 'Members' Resource Group. By removing them from this Resource Group, but keeping them in the 'Members' User Group, all appears to work fine.

          I'm very impressed with Modx and I will be buying your book smiley

          Thank you, Rob
            • 3749
            • 24,544 Posts
            Thanks for the kind words. I'm not sure what you meant, but pages can't be added to or kept in User Groups.

            The short version of protection is that an individual page is only hidden from the current user when the page is in a Resource Group and that Resource Group is connected to a User Group that the current user is not a member of (or is a member of but doesn't have the proper authority level). The connection is always via a Resource Group Access ACL entry.
              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
              • 42443
              • 17 Posts
              Well I'm then a little confused!! smiley

              By removing the pages from the Resource Group anonymous users can see this page correctly:

              http://www.internationaladoptionguide.co.uk/adoption-process/international-adoption-process-steps.html

              Active registered users, but not added to any User Group, also works fine; they get the same page.

              Users who have paid a membership fee and then added to the 'Members' User Group then get to see the whole page.

              The Members Resource Group might possibly be used elsewhere but I need to explore more.

              I'm happy however.

              Rob
                • 37261 ☆ A M B ☆
                • 113 Posts
                I've been struggling with getting logged in users who join a group to display the related resource group without logout. I've tried every solution I could think of and it is not clearly discussed anywhere except here. Please let me know if I'm correct, Developers should only use a Resource Group to protect pages IF they can reset the ACL and the only way to do this is to make the user log out and log back in. (Not sure why it cannot be reset without logout?) If a developer wants to use joinGroup API to show pages without logout, they must use a custom if/then to show/hide the content on a page that has anonymous access? It sure would be nice if joinGroup was more friendly than this.
                  • 3749
                  • 24,544 Posts
                  If you call $user->joinGroup(), this code in the modUser class file should execute:

                  unset($_SESSION["modx.user.{$this->get('id')}.userGroupNames"]);


                  It's intended to update the user's group membership during the current login, so adding a user to a user group this way should work immediately. If it doesn't, I'd consider it a bug.

                  If, however, you also add a resource to a resource group at the same time, that resource might not be available to that user.


                  There is also an adduser processor, which *doesn't* clear the $_SESSION, but does fire a system event (OnUserAddToGroup), so a plugin attached to that event could update the user's status, though I don't see that processor being called anywhere.
                    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