Remove Customize and Edit Page from standard admin bar

I had to change user roles to admin (or just allow the manage_options capabilities for my users). Which means WP thinks they are admins and gives them admin powers to customize and edit the main page. I need this to not work for the main site. I want only the superadmin (myself) to be able to customize and edit the main page.

Is there a way to delete these from the admin bar (I have WPMUDEV Branding as well with admin bar active to add menu items), I do not know how to take these items away.

Please help - screenshot added.

  • Milan

    Hello Paul,

    I hope you are having a good day and thanks for asking us. :slight_smile:

    I can't find your attached screenshot. Did you miss that ? Could you add that in your next post please ? Also what I got from your question is that you are trying to remove menus from left dashborad panel and items from admin bar right ? If not then would you please be able to add bit more information and exact menu item name which you want to remove or tweak ?

    Talk to you soon.!

    Cheers,
    Milan

  • Milan

    Hello @paulthinkgrow,

    Hope you are well today and thanks for providing me requested screenshot.

    Paul, before I jump to the final solution I would like to inform you that you need to do little work in order to hide both menus ( "Customize" and "Edit Page" )

    But before that let me inform you that "Customize" menu only comes up with some themes( some theme adds it for user friendliness ). With default twentysixteen theme I am not able to see that customize menu for page editing. But I can see "Edit Page" menu on my end certainly. So I've written this tiny snippet for removing edit page menu node only. ( For removing customize menu, you only need to do little work. )

    add_action( 'admin_bar_menu', 'remove_wp_menus', 999 );
    function remove_wp_menus( $wp_admin_bar ) {
    	if ( !current_user_can( 'manage_options' ) ) {
    		$wp_admin_bar->remove_node( 'edit' );
    	}
    }

    Now let me break above snippet in pieces so that you can understand it well. :slight_smile:
    This line,

    add_action( 'admin_bar_menu', 'remove_wp_menus', 999 );

    hooks function named "remove_wp_menus" to "admin_bar_menu" action which will be called just before admin bar menu nodes gets rendered.

    Blow line will ensure that we only remove menus for non-admins. :slight_smile:

    if ( !current_user_can( 'manage_options' ) ) {

    And finally this line is the one who will remove edit page menu from bar.

    $wp_admin_bar->remove_node( 'edit' );

    Can you see that I've passed string "edit" in parameter of class function "remove_node" ? That string is basically id of "edit page" menu node. Now for "customize" menu you need to find its node id which is very simple process. Please see this video first and then read below little info then.
    http://screencast.com/t/xlPQmx2aTf64

    If you find this process difficult, would you please enable support staff access to your site via WPMU DEV > Support > Support Staff > Grant Access so that I can make those changes for you ?

    Looking forward to hearing back Paul. :slight_smile:

    Enjoy WPMU DEV.

    Cheers,
    Milan

  • Paul

    I had to use:

    <?php
    //Removes the "Edit" menu for users who are not Super Admins of a multisite network
    add_action( 'admin_bar_menu', 'remove_wp_logo', 999 );
    
    function remove_wp_logo( $wp_admin_bar ) {
    	if ( !is_super_admin() ) {
      $wp_admin_bar->remove_node( 'edit' );
    		}        
    
    }

    But if I sign in as a regular user and type in the url to edit a page (using the page id as usual) it still allows me as a regular user to edit the main site.

    Is there a way to kill this ability only for main site?

    Kindly,

    Paul

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.