HOOK_menu_alter to remove Main Menu items for specific user roles I'm trying to add a menu link (admin/people/create?operator=1) to the Main Menu only for the user role of 'Supervisor.'

I have tried to do this:

function mymodule_menu_alter(&amp;$items) {

 if(in_array('Supervisor', array_values($user-&gt;roles)))
   $items['admin/people/create?operator=1']['type'] = {idk what goes here};

}


But I'm not sure I am on the right track.
I take you added a link to the main menu, and you want to make it appear only when the user has the right permission. In that case, hook_menu_alter() is not the right hook to implement because:


It is not used to override the links added to that menu
It is not possible to use admin/people/create?operator=1 as path for the menu link in hook_menu() or hook_menu_alter()


What you should do, after you added the link to the main menu, is to enable a module that contains the following code.

function mymodule_menu_link_alter(&amp;$link) {
  if ($link['link_path'] == 'admin/people/create?operator=1' &amp;&amp; $link['module'] == 'menu') {
    $link['options']['alter'] = TRUE;
  }    
}

function mymodule_translated_menu_link_alter(&amp;$link) {
  if ($link['link_path'] == 'admin/people/create?operator=1' &amp;&amp; $link['module'] == 'menu' &amp;&amp; user_access('use advanced user creation link')) {
    $link['hidden'] = 1;
  }
}

function mymodule_permission() {
  return array(
    'use advanced user creation link' =&gt; array(
      'title' =&gt; t('Use advanced user creation link'), 
    ),
  );
}


The $link['module'] == 'menu' part allows to alter the link that you manually added in the main menu, and not other links (i.e. added from a module). In the first function, $link['options']['alter'] = TRUE tells Drupal to invoke hook_translated_menu_link_alter() for that link; in the second function, which is actually an implementation of hook_translated_menu_link_alter(), while the first function is the implementation of hook_menu_link_alter(), $link['hidden'] = 1 actually hides the menu to the currently logged-in user.
Instead of "use advanced user creation link," you can use another permission string; as long as the permission is only given to the roles that need it, and it is unique, you can use any string you want.

I didn't find one, but if there is a module that makes the links added to the main menu visible to users with specific roles, I would use that, instead.

As side note, checking for a permission is preferable to checking for the roles the logged-in user has. The reason is that when you check for permissions, the code is always similar to if (user_access('permission to check')) {} whatever roles have that permission, while when you check for roles, the code could change from if (in_array('supervisor', array_values($user-&gt;roles))) {} to if (in_array('supervisor', array_values($user-&gt;roles)) || in_array('another role', array_values($user-&gt;roles))) {}; in other words, you are hardcoding something that you could change in the future.