Created
June 13, 2016 18:21
-
-
Save fgilio/5d579d23aaf00125fae38b39bd6f30f1 to your computer and use it in GitHub Desktop.
WordPress block user from /wp-admin
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
add_action( 'init', function () { | |
global $current_user; | |
$username = $current_user->user_login; | |
if ( ($username == 'the-username') ) { | |
if ( is_admin() && !( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) { | |
wp_redirect( home_url() ); | |
exit; | |
} | |
} | |
} ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment