OnBeforeManagerLogin
Last updated Jun 6th, 2019 | Page history | Improve this page | Report an issue
Support the team building MODX with a monthly donation.
The budget raised through OpenCollective is transparent, including payouts, and any contributor can apply to be paid for their work on MODX.
Backers
Budget
$194 per month—let's make that $500!
Learn moreEvent: OnBeforeManagerLogin¶
Fires before a user logs in to the Manager Context. By default the login continues. To deny it, the Plugin must set a non-empty event output other than true, usually an error message:
// block the login and pass the reason
$modx->event->output('Login is not allowed.');
The login aborts and shows that message. If no Plugin sets the output, or the output is true, the login proceeds. A value returned from Plugin code does not block the login; it goes to the error log.
- Service: 2 - Manager Access Events
- Group: Security
Event Parameters¶
| Name | Description |
|---|---|
| username | The provided username. |
| password | The provided password. |
| attributes | An array of: |
| - & rememberme - Boolean set if user wants password to be remembered. Passed by reference | |
| - & lifetime - The session cookie lifetime for this login. Passed by reference | |
| - & loginContext - The context key this login is occurring in. Passed by reference | |
| - & addContexts - Additional contexts in which the login is also occurring in. Passed by reference |
Event Login Workflow¶
- OnBeforeWebLogin || OnBeforeManagerLogin — block the login here (see above).
-
OnUserNotFound — runs only if the username is not found in the MODX database. Provide your own
modUserin the event output to continue the login. -
OnWebAuthentication || OnManagerAuthentication — override the default password check here. A Plugin returning
truemarks the user as verified and logged in. - OnWebLogin || OnManagerLogin — fires after the login finishes; it does not change login behavior.
Examples¶
<?php
$eventName = $modx->event->name;
switch($eventName) {
case 'OnBeforeManagerLogin':
$modx->log(modX::LOG_LEVEL_ERROR, 'A user with a name tried to log in '.$username.' and password '.$password.print_r($attributes, true));
break;
}
<?php
$eventName = $modx->event->name;
switch($eventName) {
case 'OnBeforeManagerLogin':
if ($username == 'manager'){
$user = $modx->getObject('modUser', array('username' => $username));
$user->set('active', '0');
$user->save();
}
break;
}
See Also¶
Support the team building MODX with a monthly donation.
The budget raised through OpenCollective is transparent, including payouts, and any contributor can apply to be paid for their work on MODX.
Backers
Budget
$194 per month—let's make that $500!
Learn more










