Created
May 11, 2021 13:14
-
-
Save JulioPotier/02c7fa67268bce7724937472c187383b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter( 'mepr-validate-login', 'secupress_support_11052021_no_admins' ); | |
function secupress_support_11052021_no_admins( $errors ) { | |
if ( ! isset( $_SERVER['REQUEST_METHOD'], $_POST['log'] ) || 'POST' !== $_SERVER['REQUEST_METHOD'] ) { | |
return $errors; | |
} | |
// Check for login by email address | |
$by = is_email( $_POST['log'] ) ? 'email' : 'login'; | |
$user = get_user_by( $by, $_POST['log'] ); | |
if ( ! is_wp_error( $user ) && user_can( $user, 'administrator' ) ) { | |
$errors[] = 'Administrators can not login via this page.'; | |
} | |
return $errors; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment