Recently while working on a membership site, we had to create multiple level of users. We did not want the users to have access to the WP-Admin panel because it was not customized for their experience. Rather we had put everything necessary (such as edit profile page), user dashboard etc, on the front-end. While S2 Membership Plugin allowed for us to disable wp-admin access for all users except for admins, there was no option to disable the admin bar by default. In this article, we will show you how to disable WordPress admin bar for all users except for Administrators.
need more instructions, then continue reading.
Disable Admin Bar for All Users Except for Administrators
Paste this code in your theme’s functions.php file or your site-specific plugin.
add_action(‘after_setup_theme’, ‘remove_admin_bar’);
function remove_admin_bar() {
if (!current_user_can(‘administrator’) && !is_admin()) {
show_admin_bar(false);
}
}
Disable Admin Bar for All Users
If you want to disable it for all users, then simply put use this code in your theme’s functions.php file or your site-specific plugin.
/* Disable WordPress Admin Bar for all users but admins. */show_admin_bar(false);