Skip to content
Advertisement

WordPress – Custom Change Password page

I’m trying to create custom page for Change Password under Profile. When I store/update the new user password(already change to hash value), it will logout automatically. The new password can be use to login again. Is there any way to update user password without logout afterward? I would like to avoid using plugin…Below are my code:-

JavaScript

Thank you in advance.

Advertisement

Answer

You should try using wp_set_password, instead of directly using WP_Query. While I haven’t tested it specifically, it should update the password and not require you to logout and log back in.

EDIT: The problem is the cookie becomes invalid. You’ll need to set/reset cookies using wp_set_auth_cookie. Try adding this:

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement