function civicrm_entity_contact_user_set in CiviCRM Entity 7.2
Set user entity according to contact id.
Parameters
$data:
$name:
$value:
$langcode:
$type:
$info:
Return value
null|void
2 string references to 'civicrm_entity_contact_user_set'
- civicrm_entity_entity_property_info_alter in ./
civicrm_entity.module - Here we declare Selected CiviCRM entities fields to Drupal.
- _civicrm_entity_getproperties in ./
civicrm_entity.module - Calculate fields for entities
File
- ./
civicrm_entity.module, line 3718
Code
function civicrm_entity_contact_user_set(&$data, $name, $value, $langcode, $type, $info) {
if (!is_null($data->id)) {
if ($user = user_load($value)) {
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,
));
$uf_info = civicrm_api('uf_match', 'create', array(
'version' => 3,
'contact_id' => $data->id,
'uf_id' => $user->uid,
'uf_name' => $user->name,
'domain_id' => $domain_id,
));
if (!$uf_info['is_error']) {
$data->civi_user = $user;
}
else {
return NULL;
}
}
}
}