- 🇧🇪Belgium flyke
This worked for me. It was not $form['#submit'] that I needed to alter, but instead $form['actions']['submit']['#submit'].
/** * Implements hook_form_FORM_ID_alter(). */ function mymodule_form_user_form_alter(&$form, FormStateInterface $form_state) { $form['actions']['submit']['#submit'][] = '_mymodule_homepage_redirect_submit_handler'; } /** * Custom submit callback to redirect to the homepage. */ function _mymodule_homepage_redirect_submit_handler(array &$form, FormStateInterface $form_state) { // Redirect the user to the homepage. $form_state->setRedirect('<front>'); }