Skip to content

Instantly share code, notes, and snippets.

@kcpt-steven-kohlmeyer
Created February 9, 2015 21:25
Show Gist options
  • Save kcpt-steven-kohlmeyer/59ee8037e145522fa73c to your computer and use it in GitHub Desktop.
Save kcpt-steven-kohlmeyer/59ee8037e145522fa73c 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