Block Roles From the Elementor Editor
Stops the roles you list from opening the Elementor editor, using Elementor's own role exclusion list, while they keep normal access to the WordPress editor.
Opens WPIDE on
Code
// Roles that may not use the Elementor editor.
$wpide_el_blocked_roles = array( 'author', 'contributor' );
$wpide_el_exclude_roles = function ( $value ) use ( $wpide_el_blocked_roles ) {
$roles = is_array( $value ) ? $value : array();
$roles = array_merge( $roles, $wpide_el_blocked_roles );
return array_values( array_unique( array_diff( $roles, array( 'administrator' ) ) ) );
};
add_filter( 'option_elementor_exclude_user_roles', $wpide_el_exclude_roles );
add_filter( 'default_option_elementor_exclude_user_roles', $wpide_el_exclude_roles );
Notes
Role slugs, not names: author, contributor, editor, shop_manager. Administrators can never be excluded.
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.