Quote from: galahad5 at Jul 19, 2016, 02:04 PMNot sure how I'd use the isloggedin snippet, as I already have an "isloggedin" test- if the user is logged in and they try to access the restricted page, they're allowed. If they're not logged in and they try to access it, they get sent to the login page. So that's the first part of the process and is in place. What I need to do is get the system to remember the page they were trying to access, when they log in.
It really looks like &redirectToPrior=`1` in the Login tag would work here as long as the redirection to the Login page comes on the protected page. The trick would be *not* to protect the page with the MODX permissions system, since that keeps the user from ever reaching it. So, first, remove it from all Resource Groups.
Instead, use isLoggedIn or Personalize *on the protected page* to redirect not-logged-in user to the Login page. &redirectToPrior=`1` in the Login snippet should then redirect them back to the protected page after they log in. Both of those snippet will do nothing if the user is already logged in.
Actually, I would do this, since it would be a tiny bit faster:
On the restricted page, or in its Template at the top of the body section:
The CheckLoginStatus snippet:
/* Do nothing if user is already logged in */
if ($modx->user->hasSessionContext('web')) {
return '';
}
$loginPageId = 12; /* Change to ID of Login page */
$url = $modx->makeUrl(12, "", "", "full");
$modx->sendRedirect($url);
return;
If the page is not protected in any other way, &redirectToPrior=`1` should work.