We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 15716
    • 57 Posts
    Is there a way to list multiple logout home pages (&loHomeId) like there is for login home pages (&liHomeId)...comma separated list maybe? I just want different users to go to different pages after logout depending on what group they belong to.

    Thanks!
      • 15716
      • 57 Posts
      I still need a solution to this problem. Does anyone have a clue on how to do this?

      Thanks!
        • 3749
        • 24,544 Posts
        Yes, there’s no reason why logout can’t work just like login.

        I think it could be done with just two changes.

        First in webloginpe.snippet.php:

        //change this
        $liHomeId = isset($liHomeId) ? explode(',', $liHomeId) : '';
        $loHomeId = isset($loHomeId) ? $loHomeId : '';
        
        //to this
        
        $liHomeId = isset($liHomeId) ? explode(',', $liHomeId) : '';
        $loHomeId = isset($loHomeId) ? explode(',', $loHomeId) : '';


        Note that the above will break the current snippet without the following (untested) change.

        Second, in weblogin.class.php replace the entire LogoutHomePage function with this code:

        function LogoutHomePage()
        	{
        		global $modx;
        		
        		if (!empty($this->Report))
        		{
        			return; //There was an error in the last step
        		}
        		
        		if ($this->Type == 'taconite')
        		{
        			return;
        		}
        		
        		if (!empty($this->loHomeId))
        		{
                    if (is_array($this->loHomeId))
                    {
                        foreach($this->loHomeId as $id)
                        {
                            $id = trim($id);
                            if ($modx->getPageInfo($id))
                                {
                                    $url = $modx->makeURL($id);
                                    $modx->sendRedirect($url,0,'REDIRECT_REFRESH');
                                    return;
                                }
                        }
                    }
                    else 
                    {
                        $url = $modx->makeURL($this->loHomeId);
                        $modx->sendRedirect($url,0,'REDIRECT_REFRESH');
                        return;
                    }
        		}
        		else
        		{
        			$url = $modx->makeURL($modx->documentIdentifier);
        	        $modx->sendRedirect($url,0,'REDIRECT_REFRESH');
        		}
        		return;
        	}
        	


        The only change in the second part is within the if (!empty($this->loHomeId)) {...} section so you could just paste that part in if you’re careful.

        If this works, it shouldn’t affect any current installs so it would be a good addition to the code.
          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
          • 15716
          • 57 Posts
          Didn’t work...

          MODx encountered the following error while attempting to parse the requested resource:
          « `98,112` is not numeric and may not be passed to makeUrl() »

          I understand what you tried to do, but I’m not sure how to fix this. Anyone help? Thanks all!
            • 28042 ☆ A M B ☆
            • 24,524 Posts
            Looks like your list of IDs didn’t get exploded.
              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
              • 15716
              • 57 Posts
              It does appear that way. But I can not figure out why. Could someone please help point me in the right direction. Thanks again.
                • 28042 ☆ A M B ☆
                • 24,524 Posts
                Did you replace that line in the snippet in Manager? The file weblogin.snippet.php is what gets copied into the snippet in Manager. The file itself is of no significance during use.
                  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
                  • 15716
                  • 57 Posts
                  That was the problem...

                  Thought it worked, but it doesn’t do what I want...and I’m not sure it can. Can it hold the permissions of the user so when they log out, it sends them to a page they have permission to view. I doubt this can happen because they are not logged in anymore, but could there be someway of sending them to a page based on what group they are in? I’m confused as to how I can possibly do this.

                  Thanks for all the help so far, it’s much appreciated.

                    • 3749
                    • 24,544 Posts
                    Sorry about that. I thought it was too easy. wink

                    You’d need to calculate the page before the session us destroyed in the logout function.

                    IOW, move the following code out of the logoutHomePage() function and into the logout function before the user data is lost.

                    foreach($this->loHomeId as $id)
                                    {
                                        $id = trim($id);
                                        if ($modx->getPageInfo($id))
                                            {
                                                $url = $modx->makeURL($id);
                                              // do this below instead of logoutHomePage():  $modx->sendRedirect($url,0,'REDIRECT_REFRESH');
                                             //   return;
                                            }
                                    }


                    Hope this makes sense.
                      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
                      • 15716
                      • 57 Posts
                      I’m don’t think I’m executing this right, because it won’t fully log the user out.  It will send them to the appropriate Logout page (awesome), but doesn’t actually log them out.  I put it in the logout() function after "StatusToOffline();...if I put it after that it will send the user to the default logout home, ie LoginHome (so it’s not holding the permissions and executing too late).  Where should I be putting it to make this work?

                      Thanks BobRay and Susan for the help.