WordPress admin bar is great which let you quickly access WordPress backend. But sometimes not necessary you want to show it.

this little Code will do you job.

show_admin_bar(false);

Now you can defiantly put it in condition of which role you want to show and which you don’t want to by using

current_user_can('update_core') // this is administrator.

You can check other role and capabilities here.

but if you want to show and want to remove some of its buttons that might be a need as well sometimes. you can use this little piece of code to get that done too.

// remove links/menus from the admin bar
function mytheme_admin_bar_render() {
global $wp_admin_bar;
$wp_admin_bar->remove_menu('comments'); // Removes comments
$wp_admin_bar->remove_menu('new-content'); // Removes New +
$wp_admin_bar->remove_menu('wp-logo'); // Removes WordPress Logo
$wp_admin_bar->remove_menu('search'); // Remove Search icon
}

Thats it. let us know in comments if you ever find it useful.