Hide Toolbar Unless Admin in WordPress

Sometimes you want to hide the WordPress toolbar unless the logged in user is an admin. This is especially helpful when you’re using a plugin like Restrict Content Pro, because when a new user signs up they’ll see the toolbar, which isn’t great for your brand.

function remove_toolbar_bar_unless_admin() {
    if (!current_user_can('administrator') && !is_admin()) {
        show_admin_bar(false);
    }
}

add_action('after_setup_theme', 'remove_toolbar_bar_unless_admin');

Follow IP on Twitter Like IP on Facebook

Advertisement