function realname_registration_form_alter in Realname registration 6.2
Same name and namespace in other branches
- 6 realname_registration.module \realname_registration_form_alter()
- 7.2 realname_registration.module \realname_registration_form_alter()
- 7 realname_registration.module \realname_registration_form_alter()
Implementation of hook_form_alter().
File
- ./
realname_registration.module, line 78 - For using real names during registration.
Code
function realname_registration_form_alter(&$form, $form_state, $form_id) {
if (!($form_id == 'user_register') || user_access('override realname registration')) {
return;
}
// First, we must hide the Username field from the registration form.
if (isset($form['account']) && is_array($form['account'])) {
$form['account']['name']['#type'] = 'hidden';
$form['account']['name']['#value'] = 'unset_username';
}
else {
$form['name']['#type'] = 'hidden';
$form['name']['#value'] = 'unset_username';
}
// We must ensure that the username will be accepted by Drupal core.
$form['#validate'][] = 'realname_registration_mandatory_validate';
// If regex validation is enabled, add the validation handler.
if (variable_get('realname_registration_use_validation', '')) {
$form['#validate'][] = 'realname_registration_validate';
}
}