0

Tab Tamer Module only does but so much. I want to hide a tab for anonymous users and have it active for other admin users. This just turns it off completely. Any ideas?

0

If the tab is on a path, then use hook_menu_alter to adjust the permissions via access_callback. Hide the tab for anonymous, then call into the access callback that was originally set for all other users.

Otherwise do it at the theming layer (but your path is still available which is not good).

Tab Tamer uses hook_menu_alter to set the type of the menu to MENU_CALLBACK, which just hides it. You can easily expand on that by doing that conditionally on User Role. If you implement your own module make sure it is called after Tab Tamer.

This litte bit of code in Tab Tamer does the hiding:

if ($val['action'] == 'hidden') {
   $items[$val['tabtamer_original_path']]['type'] = MENU_CALLBACK;
}

You need to change it to something like this:

if ($val['action'] == 'hidden' && user_is_anonymous()) {
   $items[$val['tabtamer_original_path']]['type'] = MENU_CALLBACK;
}
0

I added this code. Not sure if it does the trick. I need to set a hide based on permissions correct?

/**
 * Implementation of hook_menu_alter().
 * Remember to clear the menu cache after adding/editing this function.
 */
function MODULENAME_menu_alter(&$items) {
  // Removing certain local navigation tabs that are either undesired or need to be custom relocated.

  // Set these tabs to MENU_CALLBACK, so they still register the path, but just don't show the tab:
  $items['node/%node/track']['type'] = MENU_CALLBACK;
  $items['user/%user/track']['type'] = MENU_CALLBACK;
  $items['search/user/%menu_tail']['type'] = MENU_CALLBACK;

  // Fully unset these tabs and their paths, don't want them at all. This breaks the path as well:
  unset($items['user/%user/example']);
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.