Skip to main content

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.

For some weird reason the profile fields are not it used to be in Drupal 7 but you get an additional array of objects to each text field which contains all the fields to that profile.

Ex : $profile->field_fieldname['und'][0]['value'] should be rewritten something like $user_profile['field_fieldname']['#object']->field_fieldname['und'][0]['value'];

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'];

$image = $user_profile['field_first_name']['#object']->field_user_picture['und'][0]['uri'];

Just another way of getting things working instead of calling the $user object yet again.

For some weird reason, the profile fields in Drupal 7 are not what they used to be. However, the user profile object makes the additional profile fields accessible as array elements. For example:

$profile->field_fieldname['und'][0]['value']

is not available but it will work when rewritten like this:

$user_profile['field_fieldname']['#object']->field_fieldname['und'][0]['value'];

So I simply did the following in my code:

/*
 * 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 object yet again.

Source Link

For some weird reason the profile fields are not it used to be in Drupal 7 but you get an additional array of objects to each text field which contains all the fields to that profile.

Ex : $profile->field_fieldname['und'][0]['value'] should be rewritten something like $user_profile['field_fieldname']['#object']->field_fieldname['und'][0]['value'];

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'];

$image = $user_profile['field_first_name']['#object']->field_user_picture['und'][0]['uri'];

Just another way of getting things working instead of calling the $user object yet again.