using the user module, on a user page i.e user/1. a local task is created, user/%user/view. and a local tab titled view is created. What im trying to do is change the title from view, to the profiles user name

ive tried
'title' => '[user]',
'title' => '$account_name',

but it doesnt get the users name.

How can I do this?

Thanks for any help

Comments

jaypan’s picture

Are you in hook_user? If so, $account->name will give you the user's name. If you are not using hook_user, then you can get the current user's name when you are in the user pages by using:

$account = user_load(arg(1));
$username = $account->name;

Not really sure what you are asking though. Hopefully one of those two examples can help you.

Contact me to contract me for D7 -> D10/11 migrations.

BuiTraCo’s picture

maybe you want this

$GLOBALS["uid"];
$GLOBALS["nick"]; // (not sure about "nick" maybe is "user" chek on mysql hehe)

$GLOBALS_["key"];

is my fast answer i just tryed to help hehe

SamSound’s picture

thanks for the help but im not getting it.

the user module adds a local tasks to user profiles.

  $items['user/%user/view'] = array(
    'title' => 'view',
    'type' => MENU_DEFAULT_LOCAL_TASK,
    'weight' => -10,
  );

What im trying to do is change the title of the tab from view to the user account name.

So example if im user/1 the tab will say admin instead of view.

But I just dont know what to put there.

Thank you for any help

Sergeant’s picture

'title callback' => 'get_user_name',
'title arguments' => array(1),
function get_user_name($account) {
  return $account->name;
}
SamSound’s picture

works! Thanks for the help

is it possible to add profile in the title aswell?

like admins profile. im not sure where i should be adding s profile.