Remove admin bar for subscribers

I have a membership site. I need to disable the admin bar for the subscribers.

I have used this code below:

add_action(‘after_setup_theme’, ‘remove_admin_bar’);

function remove_admin_bar() {
if (!current_user_can(‘administrator’) && !is_admin()) {
show_admin_bar(false);
}
}

which removes the admin bar from the frontend for the subscriber, but when they go to their profile page wp-admin/profile.php, the admin bar is still showing there.

I am using Paid Membership Pro plugin which I think made the code not working on the backend for subscribers.

Also, I have used this code to remove the admin bar from everywhere:

if (!function_exists(‘disableAdminBar’)) {

function disableAdminBar(){

remove_action( ‘admin_footer’, ‘wp_admin_bar_render’, 1000 );

function remove_admin_bar_style_backend() {
echo ‘<style>body.admin-bar #wpcontent, body.admin-bar #adminmenu { padding-top: 0px !important; }</style>’;
}

add_filter(‘admin_head’,’remove_admin_bar_style_backend’);

}

}

add_filter(‘admin_head’,’remove_admin_bar_style_backend’);

But this code is also not working.

I just want to remove the admin bar for the subscribers from both the frontend and backend pages.

Is there any specific code I am missing? I am using Paid membership Pro.

Thank you for helping.

Read more here:: Remove admin bar for subscribers

Leave a Reply

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