Skip Navigation

[Resolved] Admin Password Reset Page

This thread is resolved. Here is a description of the problem and solution.

Problem:

Reset other user's password with Toolset forms.

Solution:

You can try these:

https://toolset.com/forums/topic/admin-password-reset-page/#post-1556935

Relevant Documentation:

This support ticket is created 4 years ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 5 replies, has 2 voices.

Last updated by MattI4840 4 years ago.

Assisted by: Luo Yang.

Author
Posts
#1555341
Annotation 2020-03-18 154245.png

Tell us what you are trying to do?

I've created an edit user form that will only be accessible by administrators for the purpose of resetting non-admin users passwords.
I've also created a validation function for the form, but it appears it's being overriden by the user forms built in validation. Every time I enter a password in both password and confirm boxes, I get a "passwords do not match" message even when they do match.

Is there any documentation that you are following?

I read through the various documentation, but the focus appears to be on allowing users to reset their own passwords, I haven't seen any documentation for what I'm attempting to do yet, but I could have missed it.

Is there a similar example that we can see?

I can upload a duplicator package for you to see this in action. The form is on the settings page, under the reset password tab. I've also provided a screenshot of the issue, and the form code is below. *Note I'm using a view to provide a list of non-admin users for the dropdown.

[creduserform]
	[cred_field field='form_messages' class='alert alert-warning']
<div class="form-group">
		<label>Select User</label>
	[cred_generic_field type='select' field='nonadmin-users']
{
"required":1,
"options":[wpv-view name="non-admin-users"]
}
[/cred_generic_field]

	<div class="form-group">
		<label>Password</label>
		[cred_field field='user_pass' id="myPassword" class='form-control' output='bootstrap']
      <label>Confirm Password</label>
		[cred_field field='user_pass2' class='form-control' output='bootstrap']
	</div>
	[cred_field field='form_submit' output='bootstrap' value='Submit' id="myConfirmPassword" class='btn btn-primary btn-lg']
[/creduserform] 

Thanks,
Matt

#1555733

Hello,

I have tried it in my localhost with a fresh WordPress installation + the latest version of Toolset plugins, with below steps:
1) Creat a user form for editing user
in form content, with only the password field + submit button:

[creduserform]
	[cred_field field='form_messages' class='alert alert-warning']
	<div class="form-group">
		<label>Password</label>
		[cred_field field='user_pass' class='form-control' output='bootstrap']
[cred_field field='user_pass2' class='form-control' output='bootstrap']
	</div>
	[cred_field field='form_submit' output='bootstrap' value='Submit' class='btn btn-primary btn-lg']
[/creduserform]

2) Test above user form in front-end

It works just fine, I can change the password without any problem

I suggest you check these in your website:
1) Make sure you are using the latest version of Toolset plugins, you can download them here:
https://toolset.com/account/downloads/

2) In case it is a compatibility problem, please deactivate all other plugins, and switch to wordpress default theme 2020, deactivate all custom PHP/JS code, and test again

3) Also check if there is any PHP/JS error in your website:
https://toolset.com/documentation/programmer-reference/debugging-sites-built-with-toolset/

4) If the problem still persists, please provide database dump file(ZIP file) of your website, also point out the problem page URL and form URL, I need to test and debug it in my localhost, thanks
https://toolset.com/faq/provide-supporters-copy-site/

#1556935

Dear Matt,

Thanks for the details, there isn't such kind of built-in feature with Toolset user form: setup a select dropdown field insider user form, and select a non-admin user and reset their password from the front end.

As a workaround, you can try these:

1) Install both Toolset Forms + Toolset Access plugins, you can download them here:
https://toolset.com/account/downloads/
The Access plugin is required here, since it can assign permission for admin user to edit other user's information(password).

2) Create a user form, for example "password-reset-form", with only reset password fields + submit button, without the select user field, see my above answer.

In section "Role of the user to create/edit", make sure you have enabled those specific user roles

3) Create a content template "edit-user", display above user form directly:
[cred_user_form form="password-reset-form" ]

4) Creat a user view "non-admin-users", query the specific non-admin user, use the same filters as your exsisted view "non-admin-users"
in view's loop, display the edit form link, for example:
[toolset-edit-user-link content_template_slug='edit-user' target='self']Edit %%USER_NICENAME%%[/toolset-edit-user-link]

5) Creat a page, display above user view:
[wpv-view name="non-admin-users"]

Test above page in front-end, you will be able to click the edit user form link, and reset the specific user's password.

More help:
https://toolset.com/documentation/getting-started-with-toolset/publish-content-from-the-front-end/forms-for-editing/

#1563021
Annotation.png
Annotation 2020-03-25 143316.png

Lou,

Thank you for your help, after reading through your suggestions I decided to change my approach slightly. As you'll see in the attached screen shot the user settings view now has separate links for editing the user profile, and for editing the password. I'm still working on the password validation, but that is a different issue.

I did want to ask one further question, and if it should be in a separate ticket just let me know. As you see in the screen shot the Add New User form is below the user settings view. Is it possible to add a drop down field to that form to select the user type to be created? I saw on the new user forms back end that there is a selection there, but that would mean I'd need to create a new user form for every user type that an administrator may want to create. Is there any way have a similar drop-down on the front end? I assume using a view to populate a generic drop down is not going to work for this, similar to how it didn't work for non-admin user selection in this ticket.

Thanks,
Matt

#1563345

I assume we are talking about the dropdown menu for user role.

The Toolset user form can only create users of one specific role, so there isn't such a built-in feature too.

Nut you can add a generic select field to the form where the role option is chosen, and then use the cred_save_data hook to run some PHP code that updates the role after the form has been submitted and the user created.

See the solution in another similar thread:
https://toolset.com/forums/topic/radio-buttons-selection-triggers-assigning-to-one-of-2-user-roles/

#1563359

My issue is resolved now. Thank you!

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.