You are here

function civicrm_entity_action_load_create_user in CiviCRM Entity 7

Same name and namespace in other branches
  1. 7.2 civicrm_entity.module \civicrm_entity_action_load_create_user()

Load or create user as appropriate.

Parameters

$entity:

int $is_active:

int $notify:

Return value

object

1 call to civicrm_entity_action_load_create_user()
civicrm_entity_user_exists_or_creatable in ./civicrm_entity.module
Condition Drupal User Account can be created or exists for contact.
1 string reference to 'civicrm_entity_action_load_create_user'
civicrm_entity_rules_action_info in ./civicrm_entity.rules.inc
Implements hook_rules_action_info().

File

./civicrm_entity.module, line 818
Implement CiviCRM entities as a Drupal Entity.

Code

function civicrm_entity_action_load_create_user($entity, $is_active = 0, $notify = 0) {
  if ($user = civicrm_entity_action_load_user($entity)) {
    if ($is_active && !$user['civicrm_user']->status) {
      $user['civicrm_user']->status = $is_active;
      $user['civicrm_user']->save;
    }
    return $user;
  }
  return civicrm_entity_action_create_user((array) $entity, $is_active, $notify);
}