You are here

function crm_core_user_sync_user_update in CRM Core 8

Same name and namespace in other branches
  1. 8.3 modules/crm_core_user_sync/crm_core_user_sync.module \crm_core_user_sync_user_update()
  2. 8.2 modules/crm_core_user_sync/crm_core_user_sync.module \crm_core_user_sync_user_update()
  3. 7 modules/crm_core_user_sync/crm_core_user_sync.module \crm_core_user_sync_user_update()

Implements hook_user_update().

File

modules/crm_core_user_sync/crm_core_user_sync.module, line 27
CRM Core User Synchronization module.

Code

function crm_core_user_sync_user_update(UserInterface $account) {

  // User update only ensures that for the given user account there is a
  // corresponding contact record.
  $related_contact_id = \Drupal::service('crm_core_user_sync.relation')
    ->getUserIndividualId($account
    ->id());
  if (empty($related_contact_id)) {
    $auto_sync_user_create = \Drupal::config('crm_core_user_sync.settings')
      ->get('auto_sync_user_create');
    if ($auto_sync_user_create) {
      \Drupal::service('crm_core_user_sync.relation')
        ->relate($account);
    }
  }
}