Skip to content

Instantly share code, notes, and snippets.

@strangerstudios
Created August 30, 2017 22:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save strangerstudios/f7be8cf6dea1ed8a9f08ba83f5c6f043 to your computer and use it in GitHub Desktop.
Save strangerstudios/f7be8cf6dea1ed8a9f08ba83f5c6f043 to your computer and use it in GitHub Desktop.
Disable the admin bar for any user who is not admin, can't edit users and can't edit posts.
/*
Disable the admin bar for any user who is not admin,
can't edit users and can't edit posts.
Add this code to a custom plugin.
*/
function my_custom_disable_admin_bar() {
if(!current_user_can('administrator') && !current_user_can('edit_users') && !current_user_can('edit_posts')) {
add_filter( 'show_admin_bar', '__return_false' );
add_action( 'admin_print_scripts-profile.php', 'habfna_hide_admin_bar_settings' );
}
}
add_action('init', 'my_custom_disable_admin_bar', 9);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment