Created
December 15, 2015 05:55
-
-
Save shizhua/49d85ee1f8a0e34366b3 to your computer and use it in GitHub Desktop.
Prevent username "admin" to login page
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( 'wp_authenticate', 'wpsites_no_admin_user' ); | |
function wpsites_no_admin_user($user){ | |
if($user == 'admin'){ | |
exit; | |
} | |
} | |
add_filter('sanitize_user', 'wpsites_sanitize_user_no_admin',10,3); | |
function wpsites_sanitize_user_no_admin($username, $raw_username, $strict){ | |
if($raw_username == 'admin' || $username == 'admin'){ | |
exit; | |
} | |
return $username; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment