You are here

function username_check_form_user_register_alter in Username originality AJAX check 6

Implementation of hook_form_$form-id_alter().

File

./username_check.module, line 35
Checks user name availability on registration page.

Code

function username_check_form_user_register_alter(&$form) {
  $mode = variable_get('username_check_mode', 'auto');
  _username_check_load_resources($mode);
  if (isset($form['account']) && $form['account']['#type'] == 'fieldset') {
    $form_group =& $form['account'];
  }
  else {
    $form_group =& $form;
  }
  if ($mode == 'manual') {
    $form_group['name']['#weight'] = -5;
    $form_group['name']['#prefix'] = '<div id="username-check-wrapper">';
    $form_group['name']['#suffix'] = '</div>';
    $form_group['username_check_button'] = array(
      '#type' => 'button',
      '#button_type' => 'button',
      // Really not supported in D6.8 and fixed in JS :'(
      '#value' => t('Check username'),
      '#prefix' => '<div id="username-check-message" class="username-check-message"></div>',
      '#weight' => -4,
    );
  }
  elseif ($mode == 'auto') {
    $module_path = drupal_get_path('module', 'username_check');
    $form_group['name']['#prefix'] = '<div id="username-check-wrapper">';
    $form_group['name']['#suffix'] = '</div><div id="username-check-message"></div><div id="username-check-informer" class="username-check-informer">&nbsp;</div>';
  }
}