Created
February 9, 2015 21:25
-
-
Save kcpt-steven-kohlmeyer/59ee8037e145522fa73c to your computer and use it in GitHub Desktop.
Wordpress: Redirect subscribers from accessing admin.
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
<?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