Home  >  Article  >  CMS Tutorial  >  How to prevent specific users from changing passwords in WordPress

How to prevent specific users from changing passwords in WordPress

angryTom
angryTomOriginal
2019-11-09 16:36:362060browse

How to prevent specific users from changing passwords in WordPress

How WordPress prohibits specific users from changing passwords

In some special circumstances, it may be necessary to prohibit users from using WordPress The built-in password reset function is to click "Forgot your password?" on the login interface to retrieve your password:

If you want to prohibit all users from using this function, you can add it in the theme's functions.php The following code:

add_filter('allow_password_reset', '__return_false' );

If you only prohibit certain users from using this function, you can add the following code to the theme’s functions.php:

add_filter('allow_password_reset', 'no_reset', 10, 2 );
function no_reset( $bool, $user_id ) {
    $ids = array( 3, 10 ); // 要禁止的用户ID
    if ( in_array( $user_id, $ids ) )
        return false;
    return true;
}

Recommended tutorial: WordPress Tutorial

The above is the detailed content of How to prevent specific users from changing passwords in WordPress. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:Modify WordPress user IDNext article:Modify WordPress user ID