You are here

function invite_user_presave in Invite 7.4

Same name and namespace in other branches
  1. 8 invite.module \invite_user_presave()
  2. 7.2 invite.module \invite_user_presave()

Implements hook_user_presave().

File

./invite.module, line 827

Code

function invite_user_presave(&$edit, $account, $category) {
  if ($account->is_new && !empty($account->mail)) {
    $invite = invite_load_from_session();
    if ($invite) {
      $roles = invite_target_roles($invite, $edit);
      if ($roles) {
        if (!isset($edit['roles']) || !is_array($edit['roles'])) {
          $edit['roles'] = array();
        }
        foreach ($roles as $role) {
          $edit['roles'][$role] = $role;
        }
      }
      if (!variable_get('invite_require_approval', FALSE)) {
        $edit['status'] = 1;
      }
      else {
        $edit['status'] = 0;
      }
    }
  }
}