If you think it would be better to show current logged in username instead of default “My account” menu item on your Drupal website, you can achieve it by editing user_menu_title function inside user.module and changing t('My account') with $GLOBALS['user']->name as shown below. You can find user.module file under ./modules/user/ in your default Drupal installation directory.
Original code;
/**
* Menu item title callback for the 'user' path.
*
* Anonymous users should see "User account", but authenticated users are
* expected to see "My account".
*/
function user_menu_title() {
return user_is_logged_in() ? t('My account') : t('User account');
}
Edited code;
/**
* Menu item title callback for the 'user' path.
*
* Anonymous users should see "User account", but authenticated users are
* expected to see "My account".
*/
function user_menu_title() {
return user_is_logged_in() ? $GLOBALS['user']->name : t('User account');
}
You may than change the style of this and “Log out” item by using default menu content id(s) in your CSS file. Here is an example;
#header ul li.menu-2 a {
color: #ffffff;
background-color: #ff6000;
border-radius:6px;
padding: 5px 11px 5px 11px;
text-decoration:none;
}
#header ul li.menu-2 a:visited{color:#ffffff;font-weight:bold;text-decoration:none;}
#header ul li.menu-2 a:link{color:#ffffff;font-weight:bold;text-decoration:none;}
#header ul li.menu-2 a:hover{color:#ffffff;font-weight:bold;text-decoration:none;}
#header ul li.menu-15 a {
color: #ffffff;
background-color: #000000;
border-radius: 6px;
padding: 5px 11px 5px 11px;
text-decoration:none;
}
#header ul li.menu-15 a:visited{color:#ffffff;font-weight:bold;text-decoration:none;}
#header ul li.menu-15 a:link{color:#ffffff;font-weight:bold;text-decoration:none;}
#header ul li.menu-15 a:hover{color:#ffffff;font-weight:bold;text-decoration:none;}
If you know a more fashionable way of doing this, please share it here with us.






RSS feed for comments on this post.




