For some weird reason, the profile fields in Drupal 7 are not itwhat they used to be in Drupal 7 but you get an additional array of objects to each text field which contains all. However, the fields to thatuser profile object makes the additional profile fields accessible as array elements. For example:
$profile->field_fieldname['und'][0]['value']
Ex : $profile->field_fieldname['und'][0]['value'] should beis not available but it will work when rewritten something like $user_profile['field_fieldname']['#object']->field_fieldname['und'][0]['value'];this:
$user_profile['field_fieldname']['#object']->field_fieldname['und'][0]['value'];
So I simply did the following
/*
- Predefine all the fields to simplified variables
- Use these variables for design purpose */
$fname = $user_profile['field_first_name']['#object']->field_first_name['und'][0]['value'];
$mname = $user_profile['field_first_name']['#object']->field_middle_name['und'][0]['value'];
$sname = $user_profile['field_first_name']['#object']->field_surname['und'][0]['value']; in my code:
$image = $user_profile['field_first_name']['#object']->field_user_picture['und'][0]['uri'];
/*
* Create simplified variables as shortcuts for all fields.
* Use these variables for read access lateron.
*/
$firstname = $user_profile['field_first_name']['#object']
->field_first_name['und'][0]['value'];
$middlename = $user_profile['field_middle_name']['#object']
->field_middle_name['und'][0]['value'];
$surname = $user_profile['field_surname']['#object']
->field_surname['und'][0]['value'];
$image = $user_profile['field_user_picture']['#object']
->field_user_picture['und'][0]['uri'];
Just another way of getting things working, instead of calling the $user$user
object yet again.