First of all, as you can see in the documentation, the function
<?php
// is deprecated
get_currentuserinfo();
has been deprecated. So, you should not build new projects with it.
Also, you are not declaring a variable for the function get_currentuserinfo, meaning that the result of that function is floating around somewhere in the air, not declared to a variable.
You should rather try:
<?php
function hide_menu_items() {
$user = wp_get_current_user();
if(current_user_can('editor')) {
//The user has the "editor" role
remove_menu_page( 'edit.php?post_type=page' );
}
}
add_action( 'admin_menu', 'hide_menu_items' );
?>
I have tested the above code and it works (removes the “pages” from the admin menu). You have to adjust the url of the remove_menu_page function to your needs.
<?php
// can check for capability and role
current_user_can('something');
?>
Usually expects a capability (e.g. ‘edit_posts’) but can also accept a role like “editor” or a custom role.