当密码更新的用户注销时的Wordpress
问题描述:
我在前端更改密码,我使用wp_user_update功能,但是当用户更改密码时它已经注销。问题是,我的老饼干没有更新,那么如何在不更新日志密码out.have任何想法?..当密码更新的用户注销时的Wordpress
global $wpdb, $current_user;
$user_id = $current_user->ID;
wp_update_user(array('ID'=>$user_id,'user_pass'=>$_POST['user_pass']));
答
在WordPress支持通过Aaron Forgue答案是3岁,但会很有趣。我不得不改变$wpdb->query()
,使其工作:
global $wpdb;
$profile_id = $_POST['prof_id'];
$username = $_POST['log_name'];
$password = $_POST['wachtwoord'];
$md5password = wp_hash_password($password);
// You may want to use $wpdb->prepare() here. As it stands, malicous code could be passed in via $_POST['prof_id'] or $_POST['log_name']
$wpdb->query($wpdb->prepare(
"
UPDATE $wpdb->users SET user_pass = %s WHERE ID = %d
",
$md5password,
$profile_id
));
// Here is the magic:
wp_cache_delete($profile_id, 'users');
wp_cache_delete($username, 'userlogins'); // This might be an issue for how you are doing it. Presumably you'd need to run this for the ORIGINAL user login name, not the new one.
wp_logout();
wp_signon(array('user_login' => $username, 'user_password' => $password));
现金去这个插件上面的绝招:http://wordpress.org/extend/plugins/change-password-e-mail/
正如Robahas提到,确保该代码运行之前头是发送,否则wp_signon()
将无法正常工作,用户无论如何都将被注销。
这是不可能的,你不能玩当前的cookie随着更改密码,因为你的网页将在更改密码后刷新 –
我认为你不知道wordpress的功能wp_update_user – Mayur
如果你知道比关闭话题更好。 –