By tax14 on
In Drupal 6, I could use the following code to display user profile fields
$profile = profile_load_profile($user);
print $user->profile_firstname ;
However, in Drupal 7, I can define additional user fields , (e.g. field_firstname) using Configuration, People, Account Settings, Manage fields. Now how do I get data from the user fields, say field_firstname as profile_load_profile() is not applicable in Drupal 7?
Thanks for your help.
Comments
Managed to get field values
I have managed to get data from the custom user fields with the following code. This code directly extracts data from the underlying tables.
I feel that there is some built-in function to get the field values that I am not aware of. If anyone knows about that function, please let me know.
<?phpglobal
user_load() and $user_fields
Chintal Desai,
Thanks for providing the code. It works.
Thanks again for sharing.
NP... cheers!!!
NP... cheers!!!
all the fields
Do you know, how to ask all the custom profile fields as an array?? Trying to figure that out for a long time now.
Do you mean to create an
Do you mean to create an array for all user fields?
How can I add this kind of
How can I add this kind of functionality to the uc_order-customer.tpl.php file for Ubercart? I have a user account field called "Allergies" that I need to print on the order invoice. I tried your code sample above, but it did not work.
Thanks!