Pardon if I've got something wrong here (** newbie **)...
It appears if you set the access control for a menu, then the admin user can't see that menu item.
One work around is to modify the patch supplied with the module for menu.inc as follows:

      // If the administrator has changed the item, reflect the change.
      if ($item->type & MENU_MODIFIED_BY_ADMIN) {
         // patch supplied with menu-by-role module
        if (module_exists('menu_per_role') && 
            // additional condition to exclude admin from filter I am suggesting:
            !user_access('administer nodes') && 
            !is_null($access = menu_per_role_access($item->mid))) {
          $_menu['items'][$item->mid]['access'] = isset($_menu['items'][$item->mid]['access']) ? $_menu['items'][$item->mid]['access'] && $access : $access;
        }
        $_menu['items'][$item->mid]['title'] = $item->title;
        $_menu['items'][$item->mid]['description'] = $item->description;
        $_menu['items'][$item->mid]['pid'] = $item->pid;
        $_menu['items'][$item->mid]['weight'] = $item->weight;
        $_menu['items'][$item->mid]['type'] = $item->type;
      }

Being very new to Drupal, I suspect their might be a nicer way?

Thanks for a great module - just what I needed!

Comments

kingandy’s picture

I've encountered this sort of thing with a few modules that do things based on roles (TinyMCE is a good one) ... though user #1 is always deemed to have permission for things, it doesn't generally get assumed to have a role. Usually I guess this is because the roles are being used to switch preferences rather than restrict access, but since this is definitely an access thing I agree that it would be a good idea to keep things visible for the Admin user.

I probably wouldn't use the 'administer nodes' pref as a check though - I can imagine cases where you might want to hide particular menu items from some node administrators.

I'd recommend checking for uid==1 instead ... or adding a 'see all menu items' type preference using hook_perm and then checking off that (since user #1 will always evaluate as true for any permission). That would also add flexibility to give other roles global access. It could tie into the permission dropdown, too, removing any global access roles from the list - saving you checking the box every time you restrict access.

That's for somebody else though, for the basic 'see all menu items' priv you'd do something like this:

 function menu_per_role_perm() {
  return array('see all menu items');
} 

Then change your code above to:

      // If the administrator has changed the item, reflect the change.
      if ($item->type & MENU_MODIFIED_BY_ADMIN) {
         // patch supplied with menu-by-role module
        if (module_exists('menu_per_role') &&
            // additional condition to exclude admin from filter I am suggesting:
            !user_access('see all menu items') &&
            !is_null($access = menu_per_role_access($item->mid))) {
          $_menu['items'][$item->mid]['access'] = isset($_menu['items'][$item->mid]['access']) ? $_menu['items'][$item->mid]['access'] && $access : $access;
        }
        $_menu['items'][$item->mid]['title'] = $item->title;
        $_menu['items'][$item->mid]['description'] = $item->description;
        $_menu['items'][$item->mid]['pid'] = $item->pid;
        $_menu['items'][$item->mid]['weight'] = $item->weight;
        $_menu['items'][$item->mid]['type'] = $item->type;
      }

... Though it might be better to make the change to the menu_per_role_access function instead, so as to avoid trouble for everyone who's already patched their menu.inc file.

teknocat’s picture

I didn't realize this issue had already been posted and filed a new issue with a simple patch that fixes the "menu_per_role_access" function in the module.

See: #503278: Super admin can't see menu items not allowing access to "authenticated user"

AlexisWilke’s picture

Status: Active » Fixed

I applied the fix from #503278

Let me know whether that is good enough, otherwise reopen the issue.

Thank you.
Alexis

kingandy’s picture

FWIW, the super-quick fix is to put user #1 into the appropriate role.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

mpaler’s picture

Version: 5.x-1.x-dev » 6.x-1.x-dev
Status: Closed (fixed) » Active

Same problem for D6 version.

Nevermind...I have a custom admin role. ..

mpaler’s picture

Status: Active » Closed (fixed)

setting back to closed.