Hide the Admin Bar for Subscribers
Hides the toolbar on the front of the site for anyone who cannot edit posts, such as subscribers and shop customers. Authors, editors and administrators keep it.
Opens WPIDE on
Code
add_filter( 'show_admin_bar', function ( $show ) {
if ( ! current_user_can( 'edit_posts' ) ) {
return false;
}
return $show;
} );
Notes
Change edit_posts to another capability (for example manage_options) to hide the bar for more roles.
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.