You are here

function email_registration_form_alter in Email Registration 5

Implementation of hook_form_alter().

File

./email_registration.module, line 42

Code

function email_registration_form_alter($form_id, &$form) {
  switch ($form_id) {
    case 'user_edit':
      if (!variable_get('email_registration_eq_email', FALSE)) {
        break;
      }
    case 'user_register':
      if ($form['_account']['#value']->uid != 1) {
        if (!isset($form['name']) && isset($form['account'])) {
          $form['account']['name']['#type'] = 'hidden';
          $form['account']['name']['#value'] = user_password();
          $form['account']['mail']['#title'] = t('E-mail');
        }
        else {
          $form['name']['#type'] = 'hidden';
          $form['name']['#value'] = user_password();
          $form['mail']['#title'] = t('E-mail');
        }
      }
      break;
    case 'user_pass':
      $form['name']['#title'] = t('E-mail');
      $form['name']['#description'] = t('Enter your e-mail address. You\'ll be sent a new password immediately.');
      break;
    case 'user_login':
      $form['name']['#title'] = t('E-mail');
      $form['name']['#description'] = t('Enter your e-mail address.');
      $form['pass']['#description'] = t('Enter the password that accompanies your e-mail.');
      $form['#validate'] = array(
        'email_registration_user_login_validate' => array(),
      ) + ($form['#validate'] ? $form['#validate'] : array());
      break;
    case 'user_login_block':
      $form['name']['#title'] = t('E-mail');
      $form['#validate'] = array(
        'email_registration_user_login_validate' => array(),
      ) + ($form['#validate'] ? $form['#validate'] : array());
      break;
  }
}