The accepted answer here by marcvangend explains how to it with hook_menu_alter. His method works, even if you skip step one (the block View).

But just out of interest: Can you do this by means of hook_menu?

So far, I've tried to put the following in hook_menu:

$items['node/%node/delete'] = array(
  'title' => 'Delete',
  'access callback' => TRUE,
  'type' => MENU_LOCAL_TASK,

However, that did not have any effect.

(Just to make clear, I just want the "Delete" tab, pointing to this existing path node/%node/delete. I don't want to put a view on it.)

2 Answers 2


You can only use hook_menu() if you're defining new paths, ideally, paths that are provided by the module implementing the hook.

If you want the Delete link to show up as a tab, hook_menu_alter is definitely the way to go, and adjusting the context value is what does the magic - as per Step 2 from marcvangend's post. If you want to change the "access callback" as per your snippet, then you can do that in hook_menu_alter() too, although I'm not sure why you'd want to let anyone delete pages?

  • I don't intend to let anyone delete pages. The access callback is just a placeholder. I was going to implement access control after I had the tab working. Mar 23, 2014 at 14:55

One of the functions that invokes hook_menu(), menu_router_build(), uses the following code.

  $callbacks = array();
  foreach (module_implements('menu') as $module) {
    $router_items = call_user_func($module . '_menu');
    if (isset($router_items) && is_array($router_items)) {
      foreach (array_keys($router_items) as $path) {
        $router_items[$path]['module'] = $module;
      $callbacks = array_merge($callbacks, $router_items);
  // Alter the menu as defined in modules, keys are like user/%user.
  drupal_alter('menu', $callbacks);

Since the code is using array_merge(), when two modules define a menu for the same path, only the last executed module would set the menu used by Drupal.

Modules should not rely on this, anyway. The correct way to alter a menu defined from another module is using the relative alter hook.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.