You are here

function noreqnewpass_form_alter in No Request New Password 7

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

Implementation of hook_form_alter().

File

./noreqnewpass.module, line 54

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', USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL)) {
      $items[] = l(t('Create new account'), 'user/register', array(
        'attributes' => array(
          'title' => t('Create a new user account.'),
        ),
      ));
    }
    $form['links'] = array(
      '#markup' => theme('item_list', array(
        'items' => $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")) {
    $form['account']['current_pass']['#access'] = FALSE;
    $form['account']['pass']['#access'] = FALSE;
  }
}