On a base Drupal install, there are 2 links included in the User Menu, My Account, and Log Out. I want to modify the My Account link to be expanded, and modify the Log Out link to be a child of the My Account link. How can I do this?

I've tried:

function MODULE_menu_alter(&$items) {
  if (isset($items['user'])) {
    $items['user']['expanded'] = true;

To at least set the My Account as expanded, but that's not working (ie. not setting the expanded property to true). And I don't know how to change the parent of the Log Out link. Preferably this could all be done without a database request.

EDIT: I recently succeeded a little bit in using:

function MODULE_menu_link_alter(&$item) {
  if ($item['link_path'] === 'user' && $link['module'] === 'system') {
    $link['expanded'] = 1;

That modifies the My account link to be expanded, but I still can't seem to modify the plid of the logout link ('user/logout').



  1. Go to yoursite.ca/admin/structure/menu/manage/user-menu
  2. Click the edit button for "My account (logged in users only)"
  3. Check the "Show as expanded" box
  4. Click Save
  5. Click the edit button for "Log out"
  6. Select "My account" under the Parent link

visual help

  1. Click Save
| improve this answer | |
  • 1
    I always prefer using built-in options over hacking core. – Christia Dec 23 '16 at 6:37

I'm not totally sure about your design.

Since both links are static (no need to add args to path), why don't you just disable User Menu and create a brand new Menu with your custom structure?

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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