WordPress Tutorial

Hide WordPress Admin Bar Based on Specific User Role

If you are seeking to hide the WordPress admin bar for a specific user role, you are at the right place. In this post, I will show the way to hide admin bar for a specific user. It’s very simple. You do not need to use any plugin for that. Please follow the below steps.

Step 01: Login to your WordPress Dashboard

Step 02: Go to Appearance >Theme Editor

Step 03: Select your theme from the marked area of right side

Step 04: Click on functions.php from your selected theme file

Step 05: Copy and paste the below code into the file and click on the Update button

// Hide admin bar

add_action('after_setup_theme', 'remove_admin_bar');

function remove_admin_bar() {
    if (current_user_can('subscriber') && !is_admin()) {
	show_admin_bar(false);
    }
}

That’s it. Thank you in advance!

Bonus: Some interesting premium WordPress themes that you might like to see for your next project.

For more details, check out this link. Thanks!

eCademy –Click to View

Gunter – Click to view

Edali – Click to View


Posted

in

,

by

Comments

Leave a Reply

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