Skip to content

Instantly share code, notes, and snippets.

@fgilio
Created June 13, 2016 18:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fgilio/5d579d23aaf00125fae38b39bd6f30f1 to your computer and use it in GitHub Desktop.
Save fgilio/5d579d23aaf00125fae38b39bd6f30f1 to your computer and use it in GitHub Desktop.
WordPress block user from /wp-admin
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