Welcome Message above user menu


Get raw version
  1. /**
  2.  * This function generates the wrapper around the tree of the menu called user_menu
  3.  * It also add a little welcome message above.
  4.  */
  5. function myTheme_menu_tree__user_menu($variables) {
  6. global $user;
  8. return t('Welcome back, ') . '<span class="username">' . $user->name. '</span>
  9. <ul class="menu">'
  10. . $variables['tree'] .
  11. '</ul>';
  12. }


malcolm's picture

Do not alter global variables, use eg. $account instead:
 $account = user_load($user->uid);
The reason why do not do it: think if someone makes a mistake in the module and alter the user_load function to pass uid = 1, you give then current user uid 1- superuser privileges!

Secondly, user_load in this function is not necessary at all.

BlackyWhoElse's picture

This snip was form a theme were I had to use fields form the user profile in this function.
So I had to use it. I updated the snipt for the core functionality.