How to add a Password reset link on user login block in Drupal

In Drupal 7, adding a link to allow users to reset their password (a “forgot my password” link) is quite easy through the hook_form_alter() hook.

/**
 * implements hook_form_alter().
 */
function mythemename_form_alter(&$form, &$form_state, $form_id)
{
  switch($form_id)
  {
    case 'user_login':
    case 'user_login_block':
      $form['links'] = array(
        array('#markup' => '<a href="/user/password/">Forgot your password?</a>'),
        '#weight' => 100,
      );
      break;
  }
}

Leave a comment

Name: (Required)

eMail: (Required)

Website:

Comment: