We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 34017
    • 898 Posts
    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; 
    }
    
      Chuck the Trukk
      ProWebscape.com :: Nashville-WebDesign.com
      - - - - - - - -
      What are TV's? Here's some info below.
      http://modxcms.com/forums/index.php/topic,21081.msg159009.html#msg1590091
      http://modxcms.com/forums/index.php/topic,14957.msg97008.html#msg97008