Created
October 30, 2017 20:32
-
-
Save vanbo/01540c86271a742b6796bc0a32737749 to your computer and use it in GitHub Desktop.
WooCommerce: Block admistrator from WC Login form
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
add_filter( 'woocommerce_login_credentials', 'prefix_check_admin_login' ); | |
function prefix_check_admin_login( $credentials ) { | |
if ( is_email( $credentials['user_login'] ) ) { | |
$user = get_user_by( 'email', $credentials['user_login'] ); | |
} else { | |
$user = get_user_by( 'login', $credentials['user_login'] ); | |
} | |
// If the user is administrator or has any rights that you want | |
if ( user_can( $user, 'administrator' ) ) { | |
// Invalidate the username to symbols | |
$credentials['user_login'] = '-_-'; | |
} | |
return $credentials; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment