简体   繁体   English

WordPress重置密码并登录用户问题

[英]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). 我的wordpress页面有一个插件,我想创建一个自定义的重置密码(与wp admin重置页面不同)。

I created a php file which is a shortcode, and this is how I reset the password: 我创建了一个简短代码的php文件,这就是我重置密码的方式:

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()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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