Hide the admin toolbar for non administrator users – but show for Editors


We have enabled the “Hide the admin toolbar for non administrator users.” which is great for Members but we do have users who have been assigned an Editor role. When they login they can no longer navigate to add posts etc.

Can we allow the Admin toolbar for Editors as well as users who have been assigned an Administrator role..?

Many Thanks

  • Ash
    • WordPress Hacker

    Hello @paul

    Welcome to WPMU community!

    I hope you are doing good and thanks for asking the question :slight_smile:

    Please try the following code:

    add_action( 'wp_head', 'hide_tolbar' );
    add_action( 'admin_head', 'hide_tolbar' );
    function hide_tolbar() {
    if( ! current_user_can( 'edit_pages' ) ) {
    #wpadminbar{display: none !important}

    You can add those codes in your functions.php in the theme, if you think your theme won’t be changed. Otherwise mu-plugins is the best solution. To use mu-plugins, go to /wp-content/ and find the folder with name ‘mu-plugins’. If there is no folder in that name, then create a folder, name it ‘mu-plugins’, create a file inside that, give any name you like and paste the code in there. You don’t need to activate that plugin. Mu-plugins means must use plugins, so it will be activated automatically always. If you use mu-plugins then add a php start tag at the beginning of the code.

    Hope it helps :slight_smile: Please feel free to ask more question if you have any.



Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.