This would work for editors. You can swap the role in and out depending on which role you are trying to target (e.g., editor
, subscriber
, etc.). This would go in functions.php
of your child theme.
function remove_menus(){
// get current login user's role
$roles = wp_get_current_user()->roles;
// test role
if( !in_array('editor',$roles)){
return;
}
//remove menu from site backend.
remove_menu_page( 'edit.php?post_type=elementor_library' ); // Elementor Templates
remove_menu_page( 'elementor' ); // Elementor
}
add_action( 'admin_menu', 'remove_menus' , 100 );