ChangePassword
Last updated Aug 9th, 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
$306 per month—let's make that $500!
Learn moreWhat is ChangePassword?¶
ChangePassword is a simple Snippet that is used in conjunction with Login, allowing users to change their password. You can place it anywhere, and it will process a form you must provide and change the user's password.
Usage¶
Simply create a Change Password form, and at the top of the page, put the snippet call. For example:
<h2>Change Password</h2>
[[!ChangePassword?
&submitVar=`change-password`
&placeholderPrefix=`cp.`
&validateOldPassword=`1`
&validate=`nospam:blank`
]]
<div class="updprof-error">[[!+cp.error_message]]</div>
<form class="form" action="[[~[[*id]]]]" method="post">
<input type="hidden" name="nospam" value="" />
<div class="ff">
<label for="password_old">Old Password
<span class="error">[[!+cp.error.password_old]]</span>
</label>
<input type="password" name="password_old" id="password_old" value="[[+cp.password_old]]" />
</div>
<div class="ff">
<label for="password_new">New Password
<span class="error">[[!+cp.error.password_new]]</span>
</label>
<input type="password" name="password_new" id="password_new" value="[[+cp.password_new]]" />
</div>
<div class="ff">
<label for="password_new_confirm">Confirm New Password
<span class="error">[[!+cp.error.password_new_confirm]]</span>
</label>
<input type="password" name="password_new_confirm" id="password_new_confirm" value="[[+cp.password_new_confirm]]" />
</div>
<div class="ff">
<input type="submit" name="change-password" value="Change Password" />
</div>
</form>
ChangePassword Properties¶
ChangePassword comes with some default properties you can override. They are:
Name | Description | Default |
---|---|---|
submitVar | The var to check for to load the ChangePassword functionality. If empty or set to false, ChangePassword will process the form on all POST requests. | logcp-submit |
fieldOldPassword | The field name of the old password field. | password_old |
fieldNewPassword | The field name of the new password field. | password_new |
fieldConfirmNewPassword | Optional. If set, the field name of the confirm password field, and will be checked against the new password field during submission. | password_new_confirm |
validateOldPassword | Set to 1 or 0. Define whether user is required to enter current password to successfully reset password. | 1 |
preHooks | What scripts to fire, if any, after the form passes validation but before save. This can be a comma-separated list of hooks, and if the first fails, the proceeding ones will not fire. A hook can also be a Snippet name that will execute that Snippet. | |
postHooks | What scripts to fire, if any, after the user has been registered. This can be a comma-separated list of hooks, and if the first fails, the proceeding ones will not fire. A hook can also be a Snippet name that will execute that Snippet. | |
redirectToLogin | If a user is not logged in and accesses this Resource, redirect them to the Unauthorized Page. | 1 |
reloadOnSuccess | If 1, the page will redirect to itself with a GET parameter to prevent double-postbacks. If 0, it will simply set a success placeholder. | 1 |
successMessage | If reloadOnSuccess is set to 0, output this message in the [prefix].successMessage placeholder. | |
placeholderPrefix | The prefix to use for all placeholders set by this snippet. | logcp. |
See Also¶
- Login.Login
- Login.Profile
- Login.UpdateProfile
- Login.Register
- Login.ConfirmRegister
- Login.ForgotPassword
- Login.ResetPassword
- Login.ChangePassword
- Login.Tutorials
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
$306 per month—let's make that $500!
Learn more