Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.