You are here

function legal_user_insert in Legal 7

Same name and namespace in other branches
  1. 8 legal.module \legal_user_insert()
  2. 7.2 legal.module \legal_user_insert()
  3. 2.0.x legal.module \legal_user_insert()

Implementation of hook_user_insert().

File

./legal.module, line 544
Module file for Legal.

Code

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

  // Record the accepted state before removing legal_accept from $edit.
  $accepted = isset($edit['legal_accept']) ? $edit['legal_accept'] : FALSE;
  $edit['legal_accept'] = NULL;
  $edit['conditions'] = NULL;
  foreach ($conditions['extras'] as $key => $label) {
    $edit[$key] = NULL;
  }

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