If I understand correctly, having

$form['actions']['submit']['#submit'][] = 'my_extra_submit';

in a hook_form_FORM_ID_alter would execute my_extra_submit after it executes the default handler.

However, running my code through a debugger, I see that in the array $form['actions']['submit']['#submit' there is only one element, and thats my_extra_submit. Thus after I press the Email New Password button, it only executes the code that is in my_extra_submit.

That wasn't the result I'm trying to achieve. I wanted to run the normal submit handler: user_pass_submit and then run my_extra_submit.

The reason for this is I want to redirect the user to a custom page after it finishes submission.

So use case:

  • user goes to /user/password
  • enters email
  • presses email new password
  • password is emailed
  • user is redirected to node/1 with a drupal_set_message("Please check your mail")

But currently whats happening is:

  • user goes to /user/password
  • enters email
  • presses email new password
  • password is NOT emailed
  • user is redirected.

Any help would be greatly appreciated!

  • Have a look in $form['#submit'] and try to add you submit handler there $form['#submit'][] = 'my_extra_submit' Jul 16, 2014 at 13:38
  • I had come back to answer my question but see that Pontus had already pointed it out. The solution was $form['#submit'][] = 'my_extra_submit'; instead of $form['actions']['submit']['#submit'][] = 'my_extra_submit'; Now everything works like it should!
    – sshrestha
    Jul 16, 2014 at 14:10


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.