Hide Toolbar Unless Admin

There are times you’ll want to hide the WordPress toolbar, but only if the logged in user is an admin. It’s helpful when using a plugin like Restrict Content Pro. Mainly because when a new user signs up they’ll see the toolbar, which isn’t a great look for your brand.

Here’s how to get rid of it:

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');

You might also likeRedirect Away from Admin in WordPress.

Inspirational Newsletter


Join the newsletter to get the best articles, tutorials and exclusive freebies every two weeks.

No spam. You can unsubscribe at any time.