Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save samjco/b0106243aeb199cfb9b93b05f08b103a to your computer and use it in GitHub Desktop.
Save samjco/b0106243aeb199cfb9b93b05f08b103a to your computer and use it in GitHub Desktop.
Wordpress: Redirect subscribers from accessing admin.
<?php
global $current_user; // Use global
get_currentuserinfo(); // Make sure global is set, if not set it.
if ( user_can( $current_user, "subscriber" ) ) {
// Disable admin bar for subscribers
show_admin_bar(false);
// If trying to view back end of wordpress
if( is_admin() ) {
wp_redirect( home_url() );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment