Quote from: BobRay at Oct 17, 2016, 06:43 PMDid you it this way?
<!--?php
/* PrivatePage snippet */
/* Redirect anyone who is not logged in */
$key = $modx----->context->get('key');
if (! $modx->user->hasSessionContext($key)) {
$loginId = '12'; /* change this to the ID of your Login page !!! */
$loginUrl = $modx->makeUrl($loginId, "", "", "full");
$docId = $modx->resource->get('id');
$currentUrl = $modx->makeUrl($docId, "", "", "full");
$_SERVER['REQUEST_URI'] = $currentUrl;
$_SERVER['HTTP_REFERER'] = $currentUrl;
$modx->sendRedirect($loginUrl);
}
return '';
I just tried that - but it said the syntax on this line was wrong:
$key = $modx--->context->get('key');
I changed it to:
$key = $modx->context->get('key');
Was that just a typo?
I tried it with the amended line above, and it still redirect to the prior page, rather than the one I want to land on.
Do you know if my Login snippet is correct though?
[[!Login?
&loginTpl=`lgnLoginTpl`
&logoutTpl=`lgnLogoutTpl`
&errTpl=`lgnErrTpl`
[[-&loginResourceId=`3`]]
&logoutResourceId=`111`
&redirectToPrior=`1`
]]
I have commented out the loginResourceId as I assume that would conflict with what we're trying to achieve?