I have a development site I am working on. We didn’t want to use htaccess or set all pages to a ’registered group’. So I created this little plugin to redirect every page to the login page if the person is not logged in. Nice simple script for when you are starting out on a development project.
$e = &$modx->Event;
switch ($e->name) {
case "OnWebPageInit":
$login_page = '4'; //Customize this if you like
$docid = $modx->documentIdentifier;
if ($modx->getLoginUserID() == '' && $docid != $login_page ) {
$redirect = $modx->makeUrl($login_page);
header('Location: '.$redirect.'');
}
break;
default :
return;
}