function regcode_user in Registration codes 6.2
Same name and namespace in other branches
- 5.3 regcode.module \regcode_user()
- 5 regcode.module \regcode_user()
- 6 regcode.module \regcode_user()
Implementation of hook_user().
1 call to regcode_user()
- regcode_voucher_validate in regcode_voucher/
regcode_voucher.module - Validate handler
File
- ./
regcode.module, line 118
Code
function regcode_user($op, &$edit, &$account, $category = NULL) {
$code_optional = variable_get('regcode_optional', FALSE);
switch ($op) {
case 'register':
$form['regcode'] = array(
'#type' => 'fieldset',
'#title' => check_plain(variable_get('regcode_fieldset_title', t('Registration Code'))),
);
$form['regcode']['regcode_code'] = array(
'#type' => 'textfield',
'#title' => check_plain(variable_get('regcode_field_title', t('Registration Code'))),
'#description' => check_plain(variable_get('regcode_field_description', t('Please enter your registration code.'))),
'#required' => !($code_optional || user_access('administer users')),
);
// Capture the code from the url and inject it into the registration form
if (isset($_GET['regcode'])) {
$form['regcode']['regcode_code']['#value'] = check_plain($_GET['regcode']);
$form['regcode']['regcode_code']['#description'] = NULL;
$form['regcode']['regcode_code']['#disabled'] = TRUE;
}
return $form;
break;
case 'validate':
if ($category === 'account' && drupal_strlen(trim($edit['regcode_code']))) {
module_invoke_all('regcode_validate', $edit, $account);
$code = regcode_use($edit['regcode_code']);
if (!is_object($code)) {
form_set_error('regcode_code', regcode_errormsg($code));
watchdog('regcode', 'User entered invalid registration code (@code)', array(
'@code' => $edit['regcode_code'],
), WATCHDOG_WARNING);
}
}
break;
case 'insert':
regcode_use_helper($edit, $account);
break;
}
}