Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?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