简体   繁体   中英

Wordpress reset password and log in user issue

I have a plugin for my wordpress page, and I want to create a custom reset password (to be different then the wp admin reset page).

I created a php file which is a shortcode, and this is how I reset the password:

get_currentuserinfo();
$userID = $current_user->ID;
wp_set_password( $_POST['pass1'], $userID );
clean_user_cache($current_user->ID);
wp_clear_auth_cookie();
wp_set_current_user($current_user->ID);
wp_set_auth_cookie($current_user->ID, true, false);
update_user_caches($current_user);

But if I refresh the page the user is logged out. I dont think I can do a redirect here, since this is a shortcode this gets executed after the headers are sent. Any tips on this?

Thanks!

您可以使用JavaScript重定向用户( window.location.assign()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM