You are here

function civicrm_entity_user_contact_get in CiviCRM Entity 7.2

Same name and namespace in other branches
  1. 7 civicrm_entity.module \civicrm_entity_user_contact_get()

Load contact entity according to user id.

Parameters

$data:

array $options:

$name:

$type:

$info:

Return value

null

3 calls to civicrm_entity_user_contact_get()
civicrm_entity_price_set_field_display_form_event in modules/civicrm_entity_price_set_field/includes/civicrm_entity_price_set_field.event_registration.inc
Form callback for event registration form
civicrm_entity_price_set_field_event_registration_form_register_as_another_ajax_callback in modules/civicrm_entity_price_set_field/includes/civicrm_entity_price_set_field.event_registration.inc
Ajax callback for Event registration form, Register as another user checkbox
_civicrm_entity_price_set_field_setup_event_registration_form_fapi in modules/civicrm_entity_price_set_field/includes/civicrm_entity_price_set_field.event_registration.inc
Helper function to setup event registration form FAPI
1 string reference to 'civicrm_entity_user_contact_get'
civicrm_entity_entity_property_info_alter in ./civicrm_entity.module
Here we declare Selected CiviCRM entities fields to Drupal.

File

./civicrm_entity.module, line 3641

Code

function civicrm_entity_user_contact_get($data, array $options, $name, $type, $info) {
  if (!module_exists('civicrm') || !function_exists('civicrm_initialize')) {
    return;
  }
  if (!civicrm_initialize()) {
    return;
  }
  $domain_id = civicrm_api('domain', 'getvalue', array(
    'version' => 3,
    'return' => 'id',
    'current_domain' => TRUE,
  ));
  $contact = civicrm_api('uf_match', 'getsingle', array(
    'version' => 3,
    'return' => 'contact_id',
    'uf_id' => $data->uid,
    'domain_id' => $domain_id,
  ));
  if (!empty($contact['contact_id'])) {
    $entity = entity_load('civicrm_contact', array(
      $contact['contact_id'],
    ));
    return $entity[$contact['contact_id']];
  }
  else {
    return NULL;
  }
}