php wordpress password change - logging me out!

前端 未结 6 1186
栀梦
栀梦 2020-12-11 20:01

I\'m trying to build a simple wordpress password change script of my own (well, based on a plugin really) - the password is successfully changed - but it logs me out after t

6条回答
  •  猫巷女王i
    2020-12-11 20:33

    Actually this:

    if(!is_wp_error($update))
    {
        wp_cache_delete($user_ID,'users');
        wp_cache_delete($user->user_login,'userlogins');
        wp_logout();
        if (wp_signon(array('user_login'=>$user->user_login,'user_password'=>$_POST['admin_pass1']),false)):
            wp_redirect(admin_url());
        endif;
        ob_start();
    }
    

    means that if there are no errors the following functions will be executed. One of this functions is wp_logout() which will be always called if the conditional block is executed.

    If it's not what you want, then you want to consider replacing:

    if(!is_wp_error($update))
    

    with:

    if(is_wp_error($update))
    

提交回复
热议问题