You are here

function genpass_form_user_profile_form_alter in Generate Password 7.2

Implements hook_form_FORM_ID_alter().

File

./genpass.module, line 29
Genpass module: automatically sets strong passwords.

Code

function genpass_form_user_profile_form_alter(&$form, &$form_state) {

  // Only change the edit form for admins modifying another user.
  if ($form['#user']->uid != $GLOBALS['user']->uid && isset($form['account']['pass'])) {

    // When editing, give admins a checkbox to change the password.
    $form['account']['pass']['#access'] = FALSE;
    $form['account']['genpass_generate'] = array(
      '#type' => 'checkbox',
      '#title' => t('Generate a new strong password. Their current password will stop working.'),
      '#prefix' => '<h3>' . t('Password') . '</h3>',
    );
    $form['#validate'][] = 'genpass_admin_edit_validate';
  }
}