Forked from kcpt-steven-kohlmeyer/redirect-subscriber.php
Created
April 24, 2016 07:51
-
-
Save samjco/b0106243aeb199cfb9b93b05f08b103a 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