I’m just getting into PHP and I’m not sure there is an adequate event in modx to really pull this off very well. but for what it’s worth this will deny access of a specific role ID to the manager and redirect them back to their "startID" (set in user configuration).
/////////////////////////////////////////////////
// M.A.D. "Manager Access Denial" v.5
//
// serves to deny access to manager based on a Role ID
//
// Written By: Sandra Brooks, Gary Hussey
/////////////////////////////////////////////////
// Deny Role
$madRole ='4'; // set this to the id of the Role you want to Deny
include_once("config.inc.php");
global $modx;
global $action;
$documentListing_array=array();
$documentListing_array=$modx->documentListing;
$REQUEST_URI=$_SERVER["REQUEST_URI"];
if ($action == 1 || $madRole == '0'){return;} //keeps script from running more than once due to frames and makes sure that the admin isn't blocked from manager
if($_SESSION["mgrRole"]==$madRole && $_REQUEST["a"]!="112"){
$user=$_SESSION["mgrInternalKey"];
$page_query="select setting_value from $dbase.modx_user_settings where user=\"$user\" and setting_name=\"manager_login_startup\"";
$page_result = $modx->db->query($page_query);
$page_row = $modx->db->getRow($page_result);
$ID=$page_row["setting_value"];
$alias=array_search($ID,$documentListing_array);
$location="http://www.nbwconline.com/$alias";
//$modx->sendRedirect($location);
//header("Location: http://www.nbwconline.com/$alias\n\n");
print "<script>window.open('".$location."','_top','',true)</script>";
exit;
}
Installation/configuration:
install:
#1. Copy and paste code into a new plugin
#2. Set the plugin to listen to
OnManagerPageInit
Config:
#1. set $madRole == ’Numeric role id’
<-- this is the numeric value of a role
Planned Updates:
#1. automatically get numeric value from role name
#2. develop a better method for redirection (
M.A.D. uses javascript in order to replace the frameset with the redirection url, making the whole thing do nothing if the client has js disabled)