You are here

function username_check_form_alter in Username originality AJAX check 5

Implementation of hook_form_alter().

File

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

Code

function username_check_form_alter($form_id, &$form) {
  if ('user_register' == $form_id) {
    $mode = variable_get('username_check_mode', 'manual');
    _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 D5.14 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>';
    }
  }
}