You are here

function redhen_contact_load_by_mail in RedHen CRM 7

Load all contact entities for an email address.

Parameters

string $mail: Required: an email address.

string $state: RedHen state. Defaults to active.

Return value

array|bool An array of RedHen Contact entities or FALSE if no match found.

5 calls to redhen_contact_load_by_mail()
redhen_contact_rules_action_fetch_by_mail in modules/redhen_contact/includes/redhen_contact.rules.inc
Rules action: fetch contact by email address.
redhen_contact_rules_condition_exists_by_email in modules/redhen_contact/includes/redhen_contact.rules.inc
Rules condition: contact exists by email address.
redhen_contact_user_registration_submit in modules/redhen_contact/redhen_contact.module
Registration form RedHen contact submit handler.
redhen_contact_user_registration_validate in modules/redhen_contact/redhen_contact.module
Registration form RedHen contact validation handler.
redhen_engagement_rules_action_score_by_mail in modules/redhen_engagement/redhen_engagement.rules.inc
Rules action: score an engagement by email address.

File

modules/redhen_contact/redhen_contact.module, line 1091
Module file for RedHen contacts.

Code

function redhen_contact_load_by_mail($mail, $state = REDHEN_STATE_ACTIVE) {
  $contacts =& drupal_static(__FUNCTION__ . $mail, FALSE);
  if (!$contacts) {
    $query = new EntityFieldQuery();
    $query
      ->entityCondition('entity_type', 'redhen_contact')
      ->fieldCondition('redhen_contact_email', 'value', $mail, '=');
    if (!is_null($state)) {
      $query
        ->propertyCondition('redhen_state', $state);
    }
    $result = $query
      ->execute();
    if (!empty($result)) {
      $contacts = redhen_contact_load_multiple(array_keys($result['redhen_contact']));
    }
  }
  return $contacts;
}