How to edit tabs/menu titles based on user roles?

Created on 11 March 2016, over 9 years ago
Updated 18 July 2025, 16 days ago

Hi all,

I am using Tab Tamer module, and it's works fine for me. Now I have some special requirement to show the tab/menu title based on user roles.
But that kind of option is not available in this module. I have gone through the modules core file tabtamer.module and found there is an hook 'tabtamer_menu_alter'.

I have implemented that hook in my custom module, and try to show the title based on user roles. But the global variable is not working for me. Following are my custom module code please have a look and let me know where is my mistake...

<?php
function custom_module_menu_alter(&$items) {
  global $user;
  if( isset( $user->roles[4] ) ){
    $items['user/%user/view']['title'] = t('Dashboard Type 2');
  }if( isset( $user->roles[3] ) ){
    $items['user/%user/view']['title'] = t('Dashboard Type 1');
  }
 return $items;
}
?> 

Thanks

Feature request
Status

Closed: outdated

Version

1.0

Component

Code

Created by

🇮🇳India mohangathala

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024