How to modify password reset content in login modal?

I can see the following in profiles/apigee_testing/modules/custom/apigee_profile_updates line hook_form_alter starting on line 38:

function apigee_profile_updates_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'user_login') {
    $form['userpasswordlink'] = array(
      '#markup' => '<br>' . l(t('Forgot your password?'), 'user/password') . '<br><br>',
      '#weight' => 100,
    );
  }

However, if I put a break point in this function, it's never hit by a debugger.

Likewise, if I try to override this in my own custom module:

function MYMODULE_user_form_user_login_alter(&$form, &$form_state, $form_id) {

  $form['userpasswordlink'] = array(
    '#markup' => '<br>' . l(t('Forgot your password?'), 'user/password') . '<br><br>',
    '#weight' => 100,
  );
}

Nothing is changed. I didn't really expect this to work, because when I step through the code with a debugger in my custom hook_form_FORM_ID_alter() function above, while I am able to modify things like the text on the submit button, I didn't actually see anything in the $form array that corresponded to the ['userpasswordlink'] field (before I added my custom code) .

I need to do something that I would think is relatively simple - change the #weight of the password link to 10 so it is printed above the sign in button. However I can't do this since I can't seem to access the userpassword link in my custom function. If I hack the Apigee profile updates module and change the #weight there to 10, it works, but I don't want to do that as a final solution to this problem.

Any assistance would be much appreciated!

1 1 107
1 REPLY 1

Great question - very clearly described. I don't know the answer right now, but let me look into it.