public function profileGetFieldValue($field_name, ProfileInterface $user_profile = NULL) {
    if ($user_profile === NULL) {
      return '';
    }

    try {
      $value = $user_profile->get($field_name)->value;
    }
    catch (\Exception $e) {
      $value = '';
    }
    return $value;
  }
public function profileGetFieldValue($field_name, ProfileInterface $user_profile = NULL) {
    if ($user_profile === NULL) {
      return '';
    }

    try {
      $value = $user_profile->get($field_name)->value;
    }
    catch (\Exception $e) {
      $value = '';
    }
    return $value;
  }
public function profileGetFieldValue ( $ field_name , ProfileInterface $ user_profile = NULL ) { if ( $ user_profile === NULL ) { return '' ; } try { $ value = $ user_profile -> get ( $ field_name ) -> value ; } catch ( \ Exception $ e ) { $ value = '' ; } return $ value ; }
Returns the value of a field for a given profile.

@param string $field_name
The field name to get the value for.
@param \Drupal\profile\Entity\ProfileInterface $user_profile
The profile to get the data for.

@return string
Returns value of the field.
Returns the value of a field for a given profile .