The global $modx is only necessary if the code is inside a function.
It looks like I need to update the FAQ.
Try this:
<?php
if ($modx->user->hasSessionContext($modx->context->get('key'))) {
$redirectPage = $modx->makeUrl(20, "", "", "full");
$modx->sendRedirect($redirectPage);
} else {
return "You are not authenticated!";
}
This should also work:
if ($modx->user->isAuthenticated()) {
If you ever really need the User ID, you need this:
$modx->getLoginUserID('web');
or
$modx->getLoginUserID($modx->context->get('key));
or if you already know the user is logged in:
BTW, I can't imagine any way that that snippet would affect things in the Manager (unless it's really a plugin or you put it in a Manager template). I suspect that it was clearing the cache that made things work again.
You might try turning off the compress_js and compress_css System Settings in System -> System Settings (type compress in the search box at the upper right).
------------------------------------------------------------------------------------------
PLEASE, PLEASE specify the version of MODX you are using.
MODX info for everyone:
http://bobsguides.com/modx.html
[ed. note: BobRay last edited this post 14 years, 3 months ago.]