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
Comment #1
Anonymous (not verified) commentedI am closing all related issues and marking as duplicate of this one:
Comment #2
baff commentedsubscribe
Comment #3
IWasBornToWin commentedsubscribe
Comment #4
Anonymous (not verified) commentedYou can click "Follow" to subscribe nowadays. Cheers.
Comment #5
jason.fisher commentedI 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.
Comment #6
serjas commentedIt was very frustrating that even superadmin cant access the disabled tabs! Something like this can fix this issue? atleast for superadmin!
Comment #7
serjas commentedComment #8
fraweg commentedHello,
Is there something new in this issue? I need also hide tabs for non admin roles. Does anyone solve that issue?
Best regards
Frank
Comment #9
milos.kroulik commentedUnfortunately, I had to stop using this module because of this issue.
Comment #10
sonicthoughts commentedThis module would be perfect for system builders like me if it had this feature - without it, it is pretty much useless.
Comment #11
lamp5