简体   繁体   English

密码更改后“出现问题”的WordPress注销消息

[英]WordPress logout after password change “something went wrong” message

I use a form and the wp_update_user function to let users change their password in the WordPress frontend. 我使用表单和wp_update_user函数让用户在WordPress前端中更改密码。 For this i use an ajax function which executes wp_update_user: 为此,我使用一个执行wp_update_user的ajax函数:

    /* CHANGE PASSWORD OF USER */
    if ( !empty($pass1 ) && !empty( $pass2 ) ) {
        if ( $pass1 == $pass2 ) {
            wp_update_user( array( 'ID' => $userID, 'user_pass' => esc_attr( $pass2 ) ) );
            echo "<div class='message-hub-success'>Passsword changed!</div>";
        } else {
             echo "<div class='message-hub-error'>The passwords you entered do not match.  Your password was not updated.</div>"; 
        }
    }

The password change is working as expected. 密码更改按预期工作。 But when the user clicks the logout-link after the password change i get the error "something went wrong" instead of a the logout and the redirect function. 但是,当用户在更改密码后单击注销链接时,出现错误“出了点问题”,而不是注销和重定向功能。 My logout link: 我的注销链接:

<a href="<?php echo wp_logout_url( home_url() ); ?>">Logout</a>

The something went wrong message is not shown on the page but on a wordpress page with a logout link: 出问题的消息未显示在页面上,但在带有注销链接的wordpress页面上: 在此处输入图片说明

The reason is that when you update the password, the user's cookies are cleared (see the documentation for wp_update_user ). 原因是,当您更新密码时,将清除用户的cookie(请参阅wp_update_user的文档)。

Then, during logout, the user's session is not available, which causes the issue you are experiencing. 然后,在注销过程中,用户会话不可用,这会导致您遇到问题。

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

相关问题 改变“哎呀,看起来像是出了问题。”的消息 - Change “Whoops, looks like something went wrong.” message WordPress给出错误消息“出了点问题。 使用REMOTE_ADDR变量时,可能尚未保存您的更改。(..)” - Wordpress gives the error “Something went wrong. Your change may not have been saved.(..)” when using the REMOTE_ADDR variable PHP 和 Ajax 出了点问题 - Something went wrong with PHP and Ajax 注销并将用户重定向回登录刀片,并显示有关在 laravel 中更改密码的消息 - Logout and redirect user back to login blade with a message on change password in laravel 在Laravel刀片错误中评论“出了点问题” - Commenting in Laravel blade error “Something went wrong” 如何注销更改用户密码后创建的所有会话? - How to logout all sessions created after user password change? Yii2:用户更改密码后从所有浏览器注销 - Yii2: logout from all browser after a user change password 在Wordpress中更改/重置密码后,将新密码发送到新数据库 - Send new password to a new database after password change/reset in Wordpress 在 wordpress 主题中,我丢失的密码链接错误如何更改该链接? - in wordpress theme my lost password link is wrong how to change that link? file_get_contents返回:对不起! 出问题了 - file_get_contents return: sorry! something went wrong
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM