modUser.changePassword
Last updated Oct 11th, 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 moremodUser::changePassword¶
Changes the password of a User. Returns true if the password changed, false otherwise.
By default, changePassword():
- matches
$oldPasswordagainst the current password withmodUser->passwordMatches(); - sets the new password;
- invokes the OnUserChangePassword event.
Pass $validateOldPassword as false to skip the old-password check.
Syntax¶
boolean changePassword (string $newPassword, string $oldPassword [, boolean $validateOldPassword = true])
Example¶
$user = $modx->getObject('modUser',array('username' => 'foobar'));
$user->changePassword('b33r4me', 'boo123');
Change the password of the currently logged-in User from ‘mypass’ to ‘s3cur3d’:
$modx->user->changePassword('s3cur3d','mypass');
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










