Working on Intranet built on Drupal where I got a module with couple of tabs.
There are two types of users, admin and non-admins. I like to change the name of the tab depending on who is viewing it.
Currently this is what I got:
function lessons_learned_menu(){
...
$items['lessons-learned/projects/viewAll'] = array(
'title' => 'View All Projects - LL',
'description' => 'Review page that lists projects that are currently open.',
'page callback' => 'pmo_lessons_learned_projects_viewAll',
'access arguments' => array('Access pmo_lessons_learned'),
'type' => MENU_LOCAL_TASK
);
...
The access argument 'Access pmo_lessons_learned', everyone has (including Admins) and 'Administrator pmo_lessons_learned' only Admins have.
Something that didn't work:
if(!user_access("Administer pmo_lessons_learned")){
$items['lessons-learned/projects/viewAll'] = array(
'title' => 'View All Projects - LL',
'description' => 'Review page that lists projects that are currently open.',
'page callback' => 'pmo_lessons_learned_projects_viewAll',
'access arguments' => array('Access pmo_lessons_learned'),
'type' => MENU_LOCAL_TASK
);
}
else
{
$items['lessons-learned/projects/viewAll'] = array(
'title' => 'Review Projects',
...
}
When I tried to debug it, I always got the user as Admin (when it was non-Admin), therefore went to the else condition every time.
So I like to change the name of the tab if the user is not Admin and vice versa.