function hook_menu_alter

You are here

7 system.api.php hook_menu_alter(&$items)
6 core.php hook_menu_alter(&$items)

Alter the data being saved to the {menu_router} table after hook_menu is invoked.

This hook is invoked by menu_router_build(). The menu definitions are passed in by reference. Each element of the $items array is one item returned by a module from hook_menu. Additional items may be added, or existing items altered.


$items: Associative array of menu router definitions returned from hook_menu().

Return value


Related topics

1 function implements hook_menu_alter()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

upload_menu_alter in modules/upload/upload.module
1 invocation of hook_menu_alter()
menu_router_build in includes/
Collect, alter and store the menu definitions.


developer/hooks/core.php, line 362
These are the hooks that are invoked by the Drupal core.


function hook_menu_alter(&$items) {
  // Example - disable the page at node/add
  $items['node/add']['access callback'] = FALSE;


1. Find or add a custom module, and add this to the [MODULENAME].module

function [MODULENAME]_menu_alter(&$items) {
$items['user']['type'] = MENU_CALLBACK;
$items['user/register']['type'] = MENU_CALLBACK;
$items['user/password']['type'] = MENU_CALLBACK;

2. Go to Site Configuration > Site Performance, Click Clear Cache

3. Open a second browser and navigate to /user and it should be gone! Yay!

I am using user selectable roles modules for my roles to be displayed and we can select those roles by checking the text boxes.but these roles are displaying by default either on registration page or on user account forms,I have no other option left with.I want to remove the registration/user account page and get the roles display on a separate page.Can you tell me how to get this done?

Instead of manually clearing the cache, try:

      drupal_set_message('The menu has been rebuilt.');

Works for me :)

function modulename_menu_alter(&$items){

$items['contact']['title'] = 'Whatever';

}//end modulename_menu_alter

If you want to remove the rss feed (/rss.xml), use the following snippet:

function MYMODULE_menu_alter(&$items) {