I have create a series of user fields. Some of these fields reference taxonomy terms, require a mobile number or are just basic text fields. I used the below to print one of the fields (the number field) inside my page.tpl.php.

global $user;
$user = user_load($user->uid); // Make sure the user object is fully loaded
$number = $user->field_phone_number['und'][0]['value'];

if (isset($number) && !empty($number)) :
print 'Cell: ' . $number;

My question is how would I go about finding the information I need to print the other fields? The potion that reads ['und'][0]['value']; in particularly is where i'm stuck. I have used devel before to find this information for node variables but I cant find similar information for custom user variables.

1 Answer 1


It's easier to have Xdebug installed so that you can add breakpoints, pause execution and inspect surrounding variables. Alternatively, you can use Kint to print out variables.

  • Hi my site is built on Drupal 7 and it seems kint only ships with D8 Devel.
    – Salmon
    Commented May 19, 2017 at 13:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.