It is possible with the login processor to login to multiple contexts, but it appears as if the Login snippet only works for a single context at the moment. It would be great if you would add an issue for this at http://github.com/splittingred/Login/issues so this doesn’t get forgotten about.
Is it possible to log in to the manager context when logging in in the front-end, using the Login snippet?
So if a user that has access to the manager, log in in the front-end they don’t need to log in one more time to access the manager...
In Login Snippet Add:
/* If user just logged in is an admin also login with mgr context */
$user = $modx->getObject('modUser',array('username'=>$_POST['username'])); // Create user object based on username logging in
$userGrp = $user->getUserGroupNames(); // Get group of user logging in
if (in_array("Administrator", $userGrp)) { // Log into mgr context if in Administrator Group
$_POST['login_context'] = 'mgr'; // Set context to log into as mgr
$modx->executeProcessor(array(
'action' => 'login',
'location' => 'security'
)); // Perform login
}
After line 73-76 containing:
/* send to login processor and handle response */
$response = $modx->executeProcessor(array(
'action' => 'login',
'location' => 'security'
));Add:
/* If user just logged out is an admin also logout with mgr context */
$userGrp = $modx->user->getUserGroupNames(); // Get group of current user
if (in_array("Administrator", $userGrp)) { // Logout mgr context if in Administrator Group
$_POST['login_context'] = 'mgr'; // Set context to logout as mgr
$modx->executeProcessor(array(
'action' => 'logout',
'location' => 'security'
)); // Perform logout
}
After lines ~120-124 after adding previous code containing:
/* send to logout processor and handle response */
$response = $modx->executeProcessor(array(
'action' => 'logout',
'location' => 'security'
));