Home > CMS Tutorial > WordPress > body text

How to prevent specific users from changing passwords in WordPress

angryTom
Release: 2019-11-09 16:36:36
Original
2062 people have browsed it

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' );
Copy after login

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;
}
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template