:::: MENU ::::

WordPress 3.3+ Toolbar Removal

I am currently in the middle of a project creating a user database in WordPress and I needed to remove the toolbar on the front end of the website so that users didn’t have access to it. This process is very simple to do.

The basic function that accomplishes this is:

1
<?php show_admin_bar(false); ?>

You can add this to your functions.php file, or anywhere in your theme above the wp_footer() function.

If you want to use this only for specific roles, try the following example:

1
2
3
4
5
<?php
if(!current_user_can('manage_options') {
  show_admin_bar(false);
}
?>

Alternatively, you can create a function to do this if you are developing a plugin, etc.

1
2
3
4
5
6
<?php
function my_function_admin_bar(){
  return false;
}
add_filter('show_admin_bar' , 'my_function_admin_bar');
?>

The only remaining issue with this fix is that there is still a 28px margin at the top of the page that WordPress adds to make space for the admin bar. The best way to remove this is to add a callback to the admin-bar function to remove this space. You should add this into your themes function.php file directly:

1
2
3
<?php
add_theme_support('admin-bar', array('callback' => '__return_false'));
?>

As a closing note, these methods only work on the toolbar on front end of your site, not on the backend.


So, what do you think ?