Due to caching, you can't modify the form_state
from hook_form_alter()
anymore. Instead, in order to set or alter the redirect destination of a form, you need to attach a #submit
handler to any action buttons available on the form, e.g.:
$form['actions']['submit']['#submit'][] = 'mymodule_form_submit';
and set the redirect destination in there:
function mymodule_form_submit($form, FormStateInterface $form_state) {
$form_state->setRedirect('user.page');
}
For the correct way to redirect in a form see How to redirect to a page after submitting a form