I'd like to show "Logged in as USERNAME" (as in drupal.org) instead of "My account" on User menu of my drupal site.
How can I do this on my drupal site?

Thanks in advance.

Comments

pixelsweatshop’s picture

shigeruw’s picture

It works!

Many thanks.

shirisha2325’s picture

How to use that module..?

Manish Jain’s picture

I had this requirement from one of my clients too.
I resolved this by writing a theming hook. Here is how you do it.

  1. Open your terminal and go to your theme directory (eg sites/all/themes/bartik)
  2. Create a file called template.php or edit it incase if it already exists.
  3. And insert the following code and replace the word theme with your theme name (eg bartik_link($variables))
function theme_link($variables) {
  if ($variables['text'] == "My account") {
    $variables['text'] = $GLOBALS['user']->name;
  }
return '<a href="' . check_plain(url($variables['path'], $variables['options'])) . '"' . drupal_attributes($variables['options']['attributes']) . '>' . ($variables['options']['html'] ? $variables['text'] : check_plain($variables['text'])) . '</a>';
}

You can find more information on theme_link() here.

sridharpandu’s picture

Overriding theme functions in template.php like the one suggested by @Manish is the preffered and light weight approach to do it. Adding another module to change a string is a bit of an overkill because modules tend to increase the apache memory footprint.

Acer Aspire 5745
[i5 430M, 3GB, 320GB]
Ubuntu 12.04 (Precise Pangolin)
Drupal 6.15, 7.x
DigitalOcean, Go Daddy, Rackspace,

shirisha2325’s picture

This code did not work for me any more suggestions..??

VM’s picture

the code may have failed because its for different version of Drupal then that which you are using. You failed to mention which version is in use so difficult to provide more support.

shirisha2325’s picture

Thanq for your response got the solution.. im using drupal 7.38 and this code worked..

function YOURTHEMENAME_translated_menu_link_alter(&$item, $map) {
global $user;
if ($item['href'] == 'user') {
$item['title'] = t($user->name);
}
}