Skip to content

Instantly share code, notes, and snippets.

@renventura
Last active February 28, 2017 22:24
Show Gist options
  • Save renventura/061d71fc48929c2f68cc to your computer and use it in GitHub Desktop.
Save renventura/061d71fc48929c2f68cc to your computer and use it in GitHub Desktop.
Prevent Administrative Admin Login from the MemberPress Login Form
<?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