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

No comments yet.

Leave a Reply