Reputation: 2329
I know that I can fetch the logged in user's name as
<?php
global $user;
print $user->name;
?>
However, I want to know how to show logged in user's full name (first and last name) and email id. Any help?
Upvotes: 0
Views: 1030
Reputation: 3662
If you are still using drupal 7. you can get the user profile like this:
global $user;
$account = user_load($user->uid);
$user_email = $account->field_profile_email[LANGUAGE_NONE][0]["email"];
$user_first_name = $account->field_first_names[LANGUAGE_NONE][0]["value"];
$user_last_name = $account->field_surname[LANGUAGE_NONE][0]["value"];
$user_full_name = "$user_first_name $user_last_name";
Upvotes: 0
Reputation: 74
You could use print_r($user) to look at the $user object. But i dont think global $user includes profile fields, so you might have to load the user object again like so:
global $user;
$account = user_load($user->uid);
print_r($account);
And the email field is usually:
$user->mail;
Upvotes: 3