Drupal comes with a lot of functionality ‘out of the box’. We add functionality by enabling modules. Sometimes tough, we do want to keep the functionality but we don’t want it to be displayed where the module displays it (in the menu).
Hiding tabs on the “/user” page
For example, Drupal’s user module does a lot of nice stuff. One of those things is letting users log in, creating accounts and let them recover passwords without the side admin having to get involved. This is nice functionality. We want this. But we might not like that those “Create new account” and “Request new password” links are displayed on the “/user” page as seen below.

We want to keep the functionality, but we don’t want all those links displayed on the same page.
How to hide menu-items?
Say hi to hook_menu_alter. This hook lets us change existing menu-items. (Menu-items such as those created by the user module.) Using this hook we can override all settings for each menu-item.
This means we can change the menu’s title, description, permissions, or even remove the page all together, with Drupal’s hook_menu_alter.
<.h3>Menu-items?
Menu-items are specified by hook_menu. Each menu-item is registered by its path. For instance, the link “Create new account” belongs to “user/register”. So, to disable that link we target the menu-item “user/register”.
Menu-type specifications
The specifications describe what title, description, access settings, page arguments… to use. As said before, it’s specified in a modules hook_menu.
For instance, Drupal’s user module specifies the following for “user/register”:
$items['user/register'] = array(
'title' => 'Create new account',
'page callback' => 'drupal_get_form',
'page arguments' => array('user_register_form'),
'access callback' => 'user_register_access',
'type' => MENU_LOCAL_TASK,
);
Menu-item’s “type” specification
Now, to just disable the menu-items, but keep the functionality, we change the menu-item’s “type” specifications.
The menu-item’s “type” specification specifies what kind of menu-item it is. Drupal provides us several options:
- MENU_NORMAL_ITEM
- MENU_CALLBACK
- MENU_SUGGESTED_ITEM
- MENU_LOCAL_ACTION
- MENU_LOCAL_TASK
- MENU_DEFAULT_LOCAL_TASK
By default, the menu type is MENU_NORMAL_ITEM which puts the menu-item in the site’s menu, usually the navigation menu.
The user menu displays the links as tabs. So it uses MENU_LOCAL_TASK and MENU_DEFAULT_LOCAL_TASK.
Type: MENU_CALLBACK
Anyway, to drop the link out of the menu we change the type to MENU_CALLBACK. This one is used to register a module’s path but to not display a menu-item for it. And that’s exactly what we want.
So, in summary, to hide the links on the user page we write the following code:
/**
* Implements hook_menu_alter().
*
* We want to change the menu-items on the login form.
*/
function gluecode_menu_alter(&$items) {
$items['user/register']['type'] = MENU_CALLBACK;
$items['user/password']['type'] = MENU_CALLBACK;
}
And this hides the “Create new account” and “Request new password” links as shown below.

3 comments
And where should I put this code?
Yes - Im new to drupal -
sac lancel en solde tournoi de mini-golf