Sometimes we want to limit a link in the tabs that shown to user.

Let say we want to remove link called "Contact"...

While this code below is sufficient to delete unwanted link from tabs :

function phptemplate_preprocess_page(&$variables, $hook) {
  my_theme_removetab('Contact', $variables);

}

function my_theme_removetab($label, &$vars) {
  $tabs = explode("\n", $vars['tabs']);
  $vars['tabs'] = '';

  foreach($tabs as $tab) {
    if(strpos($tab, '>' . $label . '<') === FALSE) {
      $vars['tabs'] .= $tab . "\n";
    }
  }
}

It doesn't select which roles that the link should be shown, so we can modify the code to get the roles that is eligible to have the link shown and hide it if the current logged user doesn't have the roles to view the link.

Let say we only allows "Contact" and "Shop" link only be visible to "vendor" roles, the link is located in /user and the site installed "me" modules


function phptemplate_preprocess_page(&$variables, $hook) {
 if (module_exists('me')) {
 $user_data = menu_get_item();
 $data = $user_data['page_arguments'][2]->roles;
 $uid = $user_data['page_arguments'][2]->uid;
} else {
 $uid = arg(1);
 $user_data = user_load($uid);
 $data = $user_data->roles;
}
  if($hook == 'page' && arg(0)=='user') {
	$roles = $data;
	$role_check = in_array('vendor', $roles) ? 'true' : 'false';
	$deletes = array ('0' => 'Shop', '1'=> 'Contact');
	
	if ($role_check == 'false') {
		foreach ($deletes as $delete) {
			my_theme_removetab($delete, $variables);
		}
	}

  }

}

The codes should be placed in your template.php, and it is for drupal 6 only.