Last active
February 28, 2017 22:24
-
-
Save renventura/061d71fc48929c2f68cc to your computer and use it in GitHub Desktop.
Prevent Administrative Admin Login from the MemberPress Login Form
This file contains hidden or 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 //* mind this opening php tag | |
/** | |
* Snippet provided by MemberPress support and modified by Ren Ventura | |
**/ | |
//* Kick admins out from MemberPress login form | |
add_filter( 'mepr-validate-login', 'kick_out_admins' ); | |
function kick_out_admins( $errors ) { | |
extract( $_POST ); | |
// Check for login by email address | |
if ( is_email( $log ) ) { | |
$user = get_user_by( 'email', $log ); | |
} else { | |
$user = get_user_by( 'login', $log ); | |
} | |
if ( $user !== false && user_can( $user, 'delete_users' ) ) { | |
$errors[] = "Admins cannot login via this form"; | |
} | |
return $errors; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment