We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 17779
    • 6 Posts
    Hello, I’m trying to understand the changes to the user system in Revolution and everything I read is not helping.

    I’m creating a client area for clients, so in Modx, I need to set permissions for each client page to a single user.

    In Evolution, I accomplished this by creating a web user group, then creating a resource group and linked them together. I then created a web user and selected the user group for that client I just created and specified a page that they will go to when they log in. Finally, when creating a page for the client, I selected the client group in the access permissions tab.

    I have tried to figure out how to do this in Revolution, but there seems a lot more options, and it seems overly complicated to achieve the same thing! Can anyone help me out how I can easily do this?

    Thanks.

      • 6537
      • 70 Posts
      I will soon be in the same position of trying to figure out Revo permissions. My first reference will probably be http://bobsguides.com/revolution-permissions.html, which a lot of people speak highly of. If you haven’t yet looked at this I reckon it’s worth a go.
        • 17779
        • 6 Posts
        I did see that page before coming here, I couldn’t really make much use of it unfortunately.

        Surely locking one page to one user should be simple enough?
          • 1778
          • 659 Posts
            • 17779
            • 6 Posts
            Thanks, that looks much simpler to follow than what I’ve seen so far, I will try it out tomorrow. You may have just saved me from Wordpress!

            Hopefully it won’t be a pain to do for each client! Converting my static website into Modx quite simply will also be a bonus, rather than the pain of Wordpress loops and what not!
              • 3749
              • 24,544 Posts
              Quote from: m165 at Jul 28, 2010, 02:28 PM

              Surely locking one page to one user should be simple enough?

              It should be, and it is in the Manager using the tree_root_id user setting. In the front end, however, I don’t know of a simple solution. You can create a resource group for each resource and a user group for each user as you did in Evolution and connect the two with a resource Group Access ACL entry.

              You could also use a snippet on each of the protected pages (or in their template) that checked the tree_root_id setting. Something like this:
              [[!MemberPage]]


              <?php 
              /*MemberPage snippet */
              
              /* kick out anonymous users */
              
              if (! $modx->user->hasSessionContext($modx->context->get('key')) ) {
                 $modx->sendUnauthorizedPage();
              }
              
              /* check current id against tree_root_id setting */
              
              if ( $modx->getOption('tree_root_id') != $modx->resource->id) {
              
                 $modx->sendUnauthorizedPage();
              }
              ?>


              To allow users to also access children of the tree_root_id page too, you’d do something like this:

              <?php 
              /*MemberPages snippet */
              /* Allow user to access a page and its children */
              
              /* kick out anonymous users */
              
              if (! $modx->user->hasSessionContext($modx->context->get('key')) ) {
                 $modx->sendUnauthorizedPage();
              }
              
              /* check current id against tree_root_id setting and it's children */
              
              $treeRoot = $modx->getOption('tree_root_id');
              
              $allowed = $modx->getChildIds($treeRoot);
              $allowed[] = $treeRoot;
              
              if (! in_array($modx->resource->id,$allowed) ) {
                 $modx->sendUnauthorizedPage();
              }
              
              ?>


              You can add the tree_root_id user setting by going to Security->Manage Users->Update User->Settings tab->Create New. Set the Key to tree_root_id and the Value to the ID of the user’s resource or container. You can use a comma-delimited list of IDs here (with no spaces) to give the user access to multiple parts of the site. If you do that, though, you’ll have to change the code in the snippets above to handle the multiple entries.
                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
                • 2878
                • 81 Posts
                Quote from: BobRay at Jul 28, 2010, 06:11 PM

                Quote from: m165 at Jul 28, 2010, 02:28 PM

                Surely locking one page to one user should be simple enough?

                It should be, and it is in the Manager using the tree_root_id user setting. In the front end, however, I don’t know of a simple solution. You can create a resource group for each resource and a user group for each user as you did in Evolution and connect the two with a resource Group Access ACL entry.

                You could also use a snippet on each of the protected pages (or in their template) that checked the tree_root_id setting. Something like this:
                [[!MemberPage]]


                <?php 
                /*MemberPage snippet */
                
                /* kick out anonymous users */
                
                if (! $modx->user->hasSessionContext($modx->context->get('key')) ) {
                   $modx->sendUnauthorizedPage();
                }
                
                /* check current id against tree_root_id setting */
                
                if ( $modx->getOption('tree_root_id') != $modx->resource->id) {
                
                   $modx->sendUnauthorizedPage();
                }
                ?>


                To allow users to also access children of the tree_root_id page too, you’d do something like this:

                <?php 
                /*MemberPages snippet */
                /* Allow user to access a page and its children */
                
                /* kick out anonymous users */
                
                if (! $modx->user->hasSessionContext($modx->context->get('key')) ) {
                   $modx->sendUnauthorizedPage();
                }
                
                /* check current id against tree_root_id setting and it's children */
                
                $treeRoot = $modx->getOption('tree_root_id');
                
                $allowed = $modx->getChildIds($treeRoot);
                $allowed[] = $treeRoot;
                
                if (! in_array($modx->resource->id,$allowed) ) {
                   $modx->sendUnauthorizedPage();
                }
                
                ?>


                You can add the tree_root_id user setting by going to Security->Manage Users->Update User->Settings tab->Create New. Set the Key to tree_root_id and the Value to the ID of the user’s resource or container. You can use a comma-delimited list of IDs here (with no spaces) to give the user access to multiple parts of the site. If you do that, though, you’ll have to change the code in the snippets above to handle the multiple entries.

                Can anything be done in Evolution where you have a manager login that really only should have manager control over one page? I can force them to the page on login but would like to be able to force a manager to auto log out when they leave the page they are assigned to. The public will also be able to view these pages. Any advice is most appreciated.

                bauhaus9
                  • 3749
                  • 24,544 Posts
                  Can anything be done in Evolution where you have a manager login that really only should have manager control over one page? I can force them to the page on login but would like to be able to force a manager to auto log out when they leave the page they are assigned to. The public will also be able to view these pages. Any advice is most appreciated.

                  bauhaus9

                  Sorry, I’ve been working in Revolution so much that I’m unreliable on Evolution questions.

                  The only thing that comes to mind is a snippet on every non-manager page that logs off any logged-in 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
                    • 2878
                    • 81 Posts
                    Quote from: BobRay at Jul 29, 2010, 02:43 PM

                    Can anything be done in Evolution where you have a manager login that really only should have manager control over one page? I can force them to the page on login but would like to be able to force a manager to auto log out when they leave the page they are assigned to. The public will also be able to view these pages. Any advice is most appreciated.

                    bauhaus9

                    Sorry, I’ve been working in Revolution so much that I’m unreliable on Evolution questions.

                    The only thing that comes to mind is a snippet on every non-manager page that logs off any logged-in user.


                    Thank you for your input.
                    I would do this but am not sure where to start.
                    Could you point me in the direction of an example that I could pull from?

                    bauhaus9
                      • 3749
                      • 24,544 Posts
                      In Evolution, it would look something like this:


                      if ($modx->userLoggedIn() ) {
                      
                         /* log user out  */
                      
                        $modx->logout();  // not sure about this. 
                        
                      
                      }
                        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