You are here

function registration_property_registrant_mail_get in Entity Registration 7.2

Same name and namespace in other branches
  1. 8.2 registration.module \registration_property_registrant_mail_get()

Callback to get $registration->registrant->mail.

1 string reference to 'registration_property_registrant_mail_get'
RegistrationMetadataController::entityPropertyInfo in lib/registration.metadata.inc

File

./registration.module, line 1848

Code

function registration_property_registrant_mail_get($registration, array $options, $name, $type) {
  $registrant = registration_get_registrant($registration);
  $type = registration_get_types($registration->type);
  $property_parts = explode(':', $type->registrant_email_property);
  $property = $property_parts[0];
  $field_col = isset($property_parts[1]) ? $property_parts[1] : NULL;
  $mail = NULL;
  if (isset($registrant->{$property})) {
    $value = $registrant->{$property}
      ->value();

    // If we have multiple values, just grab the first one:
    if (is_array($value) && isset($value[0])) {
      $value = $value[0];
    }
    if ($field_col && isset($value[$field_col])) {
      $mail = $value[$field_col];
    }
    else {
      $mail = $value;
    }
  }
  return $mail ? $mail : $registration->anon_mail;
}