这个authenticate filter hook 用于在用户登录WordPress时执行其他验证/身份验证。
add_filter(\'authenticate\', \'check_login\', 100, 3);
function check_login($user, $username, $password) {
if ( isset( $user->roles ) && is_array( $user->roles ) ) {
// Check if user is a subscriber then stop login
if (in_array( \'subscriber\', $user->roles) {
return null;
}
}
return $user;
}
我希望这会有所帮助。