• Resolved rajaito

    (@rajaito)


    My question goes beyond the basic role manager capability. I generally use the Adminimize plugin to hide certain menu items from the admin bar. But in this case, the “Edit with Elementor” menu doesn’t appear in Adminimize.

    I want to hide the menu and dropdown from specific roles that will have Elementor editing capability. However, I don’t want the user to be able to edit the headers, footers, theme files, and my Crocoblock JetEngine listings, etc.

    I found this code that works to hide the menu from the editor role. I want to add additional roles. I tried adding them in but it only works for one role at a time. Can anyone suggest the best way to do this?

    // hide edit with elementor for editor role
    add_action('wp_head', 'allteams_custom_styles', 100);
    function allteams_custom_styles() {
    	$user = wp_get_current_user();
    	if ( in_array( 'editor', (array) $user->roles ) && !is_admin() ) {
    		echo "<style>#wp-admin-bar-elementor_edit_page{display: none !important;}</style>";
    	}
    }
Viewing 4 replies - 1 through 4 (of 4 total)
  • Hi,

    Can you please send me the URL of the site?

    Thread Starter rajaito

    (@rajaito)

    Thank you for the reply @israelaz. The site is not yet online.

    Hi,

    This should be General WordPress support and not specifically related to Elementor.

    The bar is a WordPress bar, not Elementor.

    Thread Starter rajaito

    (@rajaito)

    Thank you. I have figured this out. I will share the code below if anyone else is looking to do something similar. (replace author and subscriber with other roles that have been given elementor editing access)

    // hide edit with elementor for editor, author, and subscriber roles
    
    add_action('wp_head', 'allteams_custom_styles', 100);
    function allteams_custom_styles() {
        $user = wp_get_current_user();
        if ( ( in_array( 'editor', (array) $user->roles ) || in_array( 'author', (array) $user->roles ) || in_array( 'subscriber', (array) $user->roles ) ) && !is_admin() ) {
            echo "<style>#wp-admin-bar-elementor_edit_page{display: none !important;}</style>";
        }
    }
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Remove “Edit with Elementor” on admin bar for certain roles’ is closed to new replies.