A frequent question in the issues queues for both 6.x and 7.x branches is 'How to show tab X only under condition Y?'

Examples:
- hide tabs for specific user roles, but not for admin
- hide tabs only if PHP code returns TRUE
- hide tabs depending on Context or Rules
etc.

The difficulty of doing this, is that tabs are part of the core menu system. You need to re-write each tab's access callback and add in the contingencies for roles, context, rules, PHP etc.

The way to do it for a single tab looks like this:

function hook_menu_alter(&$items) {
  $items['my/tab/path']['access callback'] = 'my_new_tab_path_callback';
}

function my_new_tab_path_callback() {
  // copy the original access callback (if any)
  // change the code to your needs, e.g. add logic for context, roles, your custom PHP
  // return TRUE or FALSE
}

In this issues we can bundle all ideas and figure out how to do it (if possible at all).

Comments

baff’s picture

subscribe

IWasBornToWin’s picture

subscribe

Anonymous’s picture

You can click "Follow" to subscribe nowadays. Cheers.

jason.fisher’s picture

I can understand the desire for Context integration, but would prefer the UI controls to be within the Content type edit form as a vertical tab group.

serjas’s picture

Status: Needs work » Patch (to be ported)

It was very frustrating that even superadmin cant access the disabled tabs! Something like this can fix this issue? atleast for superadmin!

serjas’s picture

Priority: Normal » Critical
Status: Active » Needs work
fraweg’s picture

Status: Patch (to be ported) » Needs work

Hello,

Is there something new in this issue? I need also hide tabs for non admin roles. Does anyone solve that issue?

Best regards
Frank

milos.kroulik’s picture

Issue summary: View changes

Unfortunately, I had to stop using this module because of this issue.

sonicthoughts’s picture

This module would be perfect for system builders like me if it had this feature - without it, it is pretty much useless.

lamp5’s picture

Assigned: » Unassigned
Status: Needs work » Closed (outdated)