0

I'm looking to create a script that pulls some of this information, but I need to know how to call it. For example one of the 'machine names' for one field is field_first_name how could I call this?

At the moment I'm using:

<?php
global $user;
print $user->name;
?>

Below is what I'm looking for, pulling the custom information instead of the username.

<?php
global $user;
print $user->feild_first_name;
?>
1

try $account = user_load($user -> uid) after global $user and then dsm($account) or print_r($account);, global $user get only basic data of object I think

  • got it in the end, thanks! global $user; $user_fields = user_load($user->uid); $firstname = $user_fields->field_first_name['und']['0']['value']; $lastname = $user_fields->field_surname['und']['0']['value']; – Max Chandler Aug 29 '12 at 22:27
0

Install the devel module. Now you are trying to access the currently logged in user profile so go to the user profile page like www.example.com/user and if you have proper permission you will see the complete user object user the devel tab which will be available next to the view and edit.

Also if you have the devel module you can access the global user profile like this in your code

global $user; dpm($user);

devel module: http://drupal.org/project/devel

devel debugging commands: http://ratatosk.net/drupal/tutorials/debugging-drupal.html

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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