Search code examples
drupal-7

Drupal 7 - show logged in user full name and email id


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?


Solution

  • 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;