Wordpress禁止使用 admin 用户名尝试登录

Function代码

// 禁止使用 admin 用户名尝试登录,by minirizhi.com
add_filter( 'wp_authenticate', 'minirizhi_no_admin_user' );
function minirizhi_no_admin_user($user){
    if($user == 'admin'){
        exit;
    }
}
add_filter('sanitize_user', 'minirizhi_sanitize_user_no_admin',10,3);
function minirizhi_sanitize_user_no_admin($username, $raw_username, $strict){
    if($raw_username == 'admin' || $username == 'admin'){
        exit;
    }
    return $username;
}
文章目录