We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 18174
    • 116 Posts
    firstChildRedirect is a nice snippet to use but from my view it ignores permissions completely. If the user has no permission for the 1st child he is forwarded to the not-autorized page(?). (I didn't test it, but if I look at the code it looks like, please correct me).
    Is there a firstChildRedirect snippet around which respects the permissions i.e. returns the 1st resource which has the user permission for?
    best regards
    manu
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      That's what is supposed to happen if someone tries to access a page he doesn't have permission for. FirstChildRedirect simply does what it says - redirects to the first child of the page with the snippet call on it. You would need a custom snippet or perhaps a plugin for what you want. Do you want the person redirected to the first child that the user has permission to view? That would be difficult to do, since that might be the first child, or the 23rd child, or possibly none of the children. Then what? In my opinion, you would be better off re-thinking your site structure so that protected pages aren't so mixed in with public pages, or don't have a structure that requires using that snippet.
        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
        • 4172
        • 5,888 Posts
        getResources should respect permissions.
        So, I think you can use getResources in a snippet to get the correct firstChild and redirect to that one.
          -------------------------------

          you can buy me a beer, if you like MIGX

          http://webcmsolutions.de/migx.html

          Thanks!
          • 18174
          • 116 Posts
          Hi Susan, hi Bruno

          My intention is to have a central login page where the user is forwarded to a usergroup specific welcome page after successfull login. My idea was to setup a container with resources as children that each have unique user-/resource-group permission. With a firstChildRedirect on the container the user would be forwarded as planned to its child resource. I know I imagine that might be pretty slow. But at the moment I don't have cleverer idea, do you?
          Thanks Bruno. If this is the way I'll give a try with getResources.

          best regards
          manu
            • 4172
            • 5,888 Posts
            you can also try redirectUsergroup:
            https://forums.modx.com/thread/?thread=39196&page=2
              -------------------------------

              you can buy me a beer, if you like MIGX

              http://webcmsolutions.de/migx.html

              Thanks!