How to disable WordPress Admin bar

Everyone knows that WordPress automatically inserts an admin bar at the top of the page just for logged in users. Well… I hate it as much as the grumpy cat does.

WordPress automatically inserts the admin bar at the top of the page for logged in users. Well… I hate it as much as the grumpy cat does. If you feel the same, this is how you can disable it completely:

add_filter('show_admin_bar', '__return_false');

Or, you can show the admin bar just for certain user IDs, like this:

function wcr_hide_admin_bar() {
    $users = array(1, 4, 5); // users IDs

    if (is_user_logged_in() && !in_array(get_current_user_id(), $users)) {
        show_admin_bar(false);
    }
}
add_action('set_current_user', 'wcr_hide_admin_bar');

Leave a Reply

Your email address will not be published. Required fields are marked *