OnBeforeWebLogin
Last updated Oct 14th, 2026 | 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: OnBeforeWebLogin¶
Fires before a user logs in via a non-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: 3 - Web Access Service 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.
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










