How do I edit link tabs found on the default user profile page in drupal? I'm trying to avoid having to create a user_profile.tpl.php file and rebuild the entire profile from scratch. If there's an easier way to do this, I'd rather do that. But, if I'm forced to create a custom template, how do I control the menu tabs for the profile? I haven't found any documentation that explains that part yet.
views:
83answers:
2It's in menus. The menu you want to edit is called Primary links as far as I remember.
ALSO the tabs show up when You fill in one field when creating an article, so to remove such a link You have to click it, click edit in the article and unfold the "menu link" part and clear the fields there or edit.
Edit
I didn't catch that you wanted to do generic modification of the user profile tabs, not necessarily removing them. I've modified my code to provide a few different examples of how you can modify the tabs.
Edit 2
Removed the user_access()
check on the unset as it would only be checked during the menu rebuild. Added access callback
example instead.
You can do this in a custom module with hook_menu_alter()
and unset()
:
function mymodule_menu_alter(&$items) {
// If you have the Devel module installed, uncomment to retrieve list
// of registered menu items to figure out what to unset.
// kpr($items);
// Change the name of the Edit tab
$items['user/%user_category/edit']['title'] = t('Awesome edit!');
// Disable the user edit tab, but don't disable the page if you go navigate
// directly to it
// @see http://api.drupal.org/api/function/hook_menu/6 for other types
$items['user/%user_category/edit']['type'] = MENU_CALLBACK;
// Only allow people with administer site configuration permissions to
// access the user edit and user edit account tabs.
$items['user/%user_category/edit']['access callback'] = 'user_access';
$items['user/%user_category/edit']['access arguments'] = array('administer site configuration');
$items['user/%user_category/edit/account']['access callback'] = 'user_access';
$items['user/%user_category/edit/account']['access arguments'] = array('administer site configuration');
// Completely disable the user edit tab, even if you go directly to it
// This affects all users, including user 1.
unset($items['user/%user_category/edit']);
unset($items['user/%user_category/edit/account']);
}
Each menu item is registered with Drupal using the $items
array. After enabling this module, rebuild the cache and the tabs should be modified.