Monday, December 16, 2013

Load Profile2 fields

global $user;

$profile = profile2_by_uid_load($user->uid, 'main');  

//Get exact field names by printing the array.

print "<pre>"; print_r($profile); print "</pre>"; // to know yourm all fields name

//Example to print profile fields 

print $profile->field_business_name['und'][0]['value'];

print $profile->field_first_name['und'][0]['value'];

print $profile->field_business_address['und'][0]['value'];

print $profile->field_street_address['und'][0]['value'];

print $profile->field_address_line_2['und'][0]['value'];

print $profile->field_country['und'][0]['iso2'];

print $profile->field_state_province_region['und'][0]['value']];

print $profile->field_city['und'][0]['value']];

print $profile->field_postal_zip_code['und'][0]['value']];

print $profile->field_phone['und'][0]['value'];

print $profile->field_fax_number['und'][0]['value'];

No comments:

Post a Comment