1

how to add a redirection after user's password change without modifying Drupal Core? (user_profile_form_submit)

4

You can add your own submit handler to the form using hook_form_alter, and set your redirect here.

Ex:

<?php
function my_module_form_alter(&$form, &$form_state, $form_id)
{
  if($form_id == 'user_profile_form')
  {
    $form['#submit'][] = 'my_module_profile_form_submit';
  }
}

function my_module_profile_form_submit($form, &$form_state)
{
  $form_state['redirect'] = 'some/path';
}
?>
  • in my_module_profile_form_submit, d doublecheck if the user submitting the form (global $user) is the user being altered by the form ($form['#user']). otherwise you might break functionality for admins when editing a user. – commonpike Jun 8 '15 at 10:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy