You are here

function noreqnewpass_form_alter in No Request New Password 6

Same name and namespace in other branches
  1. 8 noreqnewpass.module \noreqnewpass_form_alter()
  2. 5 noreqnewpass.module \noreqnewpass_form_alter()
  3. 7.2 noreqnewpass.module \noreqnewpass_form_alter()
  4. 7 noreqnewpass.module \noreqnewpass_form_alter()

Implementation of hook_form_alter().

File

./noreqnewpass.module, line 40

Code

function noreqnewpass_form_alter(&$form, $form_state, $form_id) {
  if ($form_id == 'user_login_block' && variable_get('noreqnewpass_disabled', true)) {
    $items = array();
    if (variable_get('user_register', 1)) {
      $items[] = l(t('Create new account'), 'user/register', array(
        'title' => t('Create a new user account.'),
      ));
    }
    $form['links'] = array(
      '#value' => theme('item_list', $items),
    );
  }
  if (($form_id == 'user_login_block' || $form_id == 'user_login') && variable_get('noreqnewpass_disabled', true)) {
    $key = array_search('user_login_final_validate', $form['#validate']);
    $form['#validate'][$key] = 'noreqnewpass_user_login_final_validate';
  }

  // Remove pass field from user edit form if he cant change
  if ($form_id == 'user_profile_form' && !user_access("can change your own password")) {
    unset($form['account']['pass']);
  }
}