hosting

Disable wp admin bar

Recently while working on a membership site I needed to stop the admin bar from showing up for all users apart from site admins this follows on for my last weeks post about Blocking access from wp admin if you’ve blocked wp admin access you may also want to get rid of the admin bar.

the reason why this was done on my site was I only wanted the user to have front end access to deal with the management of there account without being able to access the admin area as this wasn’t optimised for there use
this code in your theme’s functions.php file or your site-specific plugin.

Disable Admin Bar for All Users Except for Administrators

Paste this code in your theme’s functions.php file or your site-specific plugin.
1 add_action(‘after_setup_theme’, ‘remove_admin_bar’);
2

3 function remove_admin_bar() {
4 if (!current_user_can(‘administrator’) && !is_admin()) {
5 show_admin_bar(false);
6 }
7 }

lets say you want to go one step further and remove the admin bar for everyone simply put use this code in your theme’s functions.php file or your site-specific plugin.

If you want to disable it for all users, then

1/* Disable WordPress Admin Bar for all users but admins. */
2 show_admin_bar(false);

One Response to Disable wp admin bar

  1. Sarah 15th April 2014 at 8:49 pm #

    Thanks a lot for giving eonryvee such a splendid opportunity to read in detail from here. It’s usually so cool plus full of a lot of fun for me and my office colleagues to visit your web site particularly 3 times a week to read the new secrets you will have. And of course, we’re usually amazed with the effective pointers you serve. Certain 1 ideas in this article are certainly the very best we have ever had.

Leave a Reply to Sarah Click here to cancel reply.