You are here

function regcode_voucher_user in Registration codes 6.2

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

Implementation of hook_user().

This adds an extra formset to the user edit page which allows the user to save a code when editing their profile page.

File

regcode_voucher/regcode_voucher.module, line 42

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' => variable_get('regcode_voucher_fieldset_title', t('Registration Code')),
        );
        $form['regcode']['regcode_code'] = array(
          '#type' => 'textfield',
          '#title' => variable_get('regcode_voucher_field_title', t('Registration Code')),
          '#description' => variable_get('regcode_voucher_field_description', t('Please enter your registration code.')),
          '#required' => FALSE,
        );
      }
      return $form;
      break;
    case 'update':

      // This will only fire if regcode_code is filled in
      $code = regcode_use_helper($edit, $account);
      if (is_object($code)) {
        drupal_set_message(variable_get('regcode_voucher_message', t('Voucher code used successfully.')));
      }
      break;
  }
}