Created
July 2, 2014 23:25
-
-
Save mikeselander/80ed5b81804c55bae347 to your computer and use it in GitHub Desktop.
Remove admin bar & keep end users out of the WordPress backend
This file contains hidden or 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
/** | |
* Remove admin bar & admin access for non-managers & non-admins | |
* @access public | |
* @since 0.1.0 | |
*/ | |
add_action('admin_init', 'no_mo_dashboard'); | |
add_action('after_setup_theme', 'remove_admin_bar'); | |
function no_mo_dashboard() { | |
if ( ! current_user_can( 'edit_others_posts' ) && '/wp-admin/admin-ajax.php' != $_SERVER['PHP_SELF'] ) { | |
wp_redirect( site_url() ); exit; | |
} | |
} | |
function remove_admin_bar() { | |
if (!current_user_can('administrator') && !is_admin()) { | |
show_admin_bar(false); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment