In the user menu, I would like the menu link for the "user" path to use the dynamic link title from the title callback, instead of a custom link title.

I know I could alter this on the theme layer, e.g. with hook_preprocess_menu_link(). But somehow I have the feeling there must be something simpler, that works out of the box..

Any ideas?

1 Answer 1


Menu links that are registered through hook_menu() do this already, so if you are using the system-provided menu link, it should pick up whatever you have altered "title callback" to be instead.

The system-provided 'user' menu link is being altered by user.module to prevent it from showing up to anonymous users (see user_menu_link_alter(), user_translated_menu_link_alter()). That might be getting in the way of what you want, in which case you could bypass/unset the user module implementation in a hook_module_implements_alter() function.

If you're using a custom menu link created through the UI, I don't believe you will be able to make that link title dynamic short of implementing hook_menu_link_alter() and hook_translated_menu_link_alter(). That's probably more work than intercepting it at the theme layer, though.

  • I assume this behavior (taking the title from the title callback) only works if the menu link is not "overridden", right?
    – donquixote
    Jan 27, 2016 at 6:40
  • Yep. Overriding a menu link title in the UI more or less makes it static.
    – Les Lim
    Jan 27, 2016 at 17:08
  • I swear I knew all of this once :)
    – donquixote
    Jan 27, 2016 at 18:01

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.