You are here

function gdpr_consent_user_insert in GDPR Consent 7

Implements hook_user_insert().

File

./gdpr_consent.module, line 708
Module file for GDPR Consent.

Code

function gdpr_consent_user_insert(&$edit, $account, $category) {
  global $user;
  $conditions = gdpr_consent_get_conditions($account->language);
  if (empty($conditions['conditions'])) {
    return;
  }

  // Record the accepted state before removing gdpr_consent_accept from $edit.
  $accepted = isset($edit['gdpr_consent_accept']) ? $edit['gdpr_consent_accept'] : FALSE;
  $edit['gdpr_consent_accept'] = NULL;
  $edit['conditions'] = NULL;

  // Don't insert if user is already registered (administrator).
  if (!empty($user->uid)) {
    return;
  }
  if ($accepted) {
    gdpr_consent_save_accept($conditions['version'], $conditions['revision'], $conditions['language'], $conditions['tc_id'], $account->uid);
  }
}