How to remove the admin bar for logged users in WordPress?

If you have a wordpress web page with registered users, you can see that the admin bar on top is shown where the users are logged. This issue could broke the design of you web page or give access to zones that you want keep hidde. To remove this bar you can add this code to you functions.php file, this code removes the admin bar for all users except the adminitrator.

1
2
3
4
5
6
7
add_action('after_setup_theme', 'hide_admin_bar');

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

If you want remove the admin bar to the administrator too, only remove the conditional.

1
2
3
4
5
6
add_action('after_setup_theme', 'hide_admin_bar');

function hide_admin_bar() {
show_admin_bar(false);
}
}

Cheers

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>