You are here

function regcode_voucher_user in Registration codes 6

Same name and namespace in other branches
  1. 6.2 regcode_voucher/regcode_voucher.module \regcode_voucher_user()

Implementation of hook_user().

File

regcode_voucher/regcode_voucher.module, line 39

Code

function regcode_voucher_user($op, &$edit, &$account, $category = NULL) {
  switch ($op) {
    case 'form':
      $form = array();
      if (_regcode_voucher_accesscheck($account, 'editform')) {
        $form['regcode'] = array(
          '#type' => 'fieldset',
          '#title' => check_plain(variable_get('regcode_voucher_fieldset_title', t('Registration Code'))),
        );
        $form['regcode']['regcode_code'] = array(
          '#type' => 'textfield',
          '#title' => check_plain(variable_get('regcode_voucher_field_title', t('Registration Code'))),
          '#description' => check_plain(variable_get('regcode_voucher_field_description', t('Please enter your registration code.'))),
          '#required' => FALSE,
        );
      }
      return $form;
      break;
    case 'update':
      if (!empty($edit['regcode_code'])) {
        regcode_user('insert', $edit, $account);
        drupal_set_message(check_plain(variable_get('regcode_voucher_message', 'Voucher code used successfully.')));
      }
      break;
  }
}