We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 14883 ☆ A M B ☆
    • 450 Posts
    Is there any way to specify an alternate loginResourceId if the user that just logged in is a member of a particular group? I thought of using a snippet call as the value of loginResourceId, but then realized that it would get parsed before the user is logged in so it wouldn’t work. I imagine there’s a way to brute-force change it with a post-hook, but I’m not sure how that would work.

    I think a nice enhancement would be an input parameter where the user could specify a custom snippet that would check group membership (according to whatever logic they decide to use) and output a corresponding resource ID that the user would then get forwarded to.
      • 28215
      • 4,149 Posts
      splittingred Reply #2, 16 years ago
      Use a postHook:

      $isMember = $modx->user->isMember(array('myGroup','AnotherGroup'));
      if ($isMember) {
         $url = $modx->makeUrl($myResourceId);
         $modx->sendRedirect($url);
      }
      return true;
      
        shaun mccormick | bigcommerce mgr of software engineering, former modx co-architect | github | splittingred.com
        • 17851
        • 213 Posts
        hmmm, I'm having a hard time with this one. Doesn't seem to be the same as the register posthook.

        1. "$hook" doesn't seem to be available
        2. if I check the member, as you suggested, it does not do anything, just logs in and stays on the login page (Logout now appears)
        3. when I logout, it redirects me to the proper page based on my user group

        Here's my snippet call:
        [[!Login? &loginTpl=`lgnLoginTpl` &logoutTpl=`lgnLogoutTpl` &tplType=`modChunk` &postHooks=`ed.loginRoute`]]
        

        Here's my posthook:
        $isMember = $modx->user->isMember('Carriers');
        if ($isMember) {
           $url = $modx->makeUrl(644);
           $modx->sendRedirect($url);
        }
        return true;
          Mark Macatee
          President
          Power 10 Solutions
          http://www.power10solutions.com