Created
December 11, 2013 05:43
-
-
Save azanebrain/7905601 to your computer and use it in GitHub Desktop.
Don't allow subscribers to view the admin panels or the admin bar
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
/** | |
* Disable admin bar on the frontend of your website | |
* for subscribers. | |
*/ | |
function themeblvd_disable_admin_bar() { | |
if( ! current_user_can('edit_posts') ) | |
add_filter('show_admin_bar', '__return_false'); | |
} | |
add_action( 'after_setup_theme', 'themeblvd_disable_admin_bar' ); | |
/** | |
* Redirect back to homepage and not allow access to | |
* WP admin for Subscribers. | |
*/ | |
function themeblvd_redirect_admin(){ | |
if ( ! current_user_can( 'edit_posts' ) ){ | |
wp_redirect( site_url() ); | |
exit; | |
} | |
} | |
add_action( 'admin_init', 'themeblvd_redirect_admin' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment