drupaldrupal-7drupal-navigation

Drupal 7: Make a custom module create a menu item in the user menu


Just like the title says. If you add an item to the hook_menu function and declare it of type 'MENU_NORMAL_ITEM' it shows up in the navigation menu. Is there a way to create an item there that shows up in the user menu?


Solution

  • See the drupal documentation for the hook_menu function. with your custom menu items you can declare 'menu_name', and you pass the name of the menu you want your item added to. In your case it would be 'user-menu':

    <?php
    
    function mymodule_menu(){
        $items['mymodulepath'] = array(
            'title' => 'My Module User Item',
            'type' => MENU_NORMAL_ITEM,
            'menu_name' => 'user-menu',
        );
    
        return $items;
    }