If you have question, How to “Hide Frontend Admin Bar and Toolbar” according to our User Roles. Please see the below methods to hide the admin bar from front side.
Don’t Show Admin Bar For All Users
If you want to hide the admin bar for every user including admin, editor, use the below code
add_filter('show_admin_bar', '__return_false');
show_admin_bar(false);
Don’t Show Admin Bar Based On User Capabilities
Below code is used to hide the admin bar every user except who have the “edit_posts” capabilities role.
add_action('set_current_user', 'hide_admin_bar_in_front_site'); function hide_admin_bar_in_front_site() { if (current_user_can('edit_posts')) { show_admin_bar(false); } }
This code is used to hide the admin bar every user except who have the “manage_options” capabilities role.
if ( ! current_user_can( 'manage_options' ) ) { show_admin_bar( false ); }
Hide the Admin Bar Using Custom Function
function my_function_admin_bar() { return false; } add_filter( 'show_admin_bar' , 'my_function_admin_bar');