In Drupal 7 profile2 module, want to make profile2 edit form to stay on the form itself after clicking SAVE button.

With the following code, it stays on the form itself and displays the values correctly. But it does not save actually. When coming back to the form, it still shows the previous values there.

So the following code makes the submitting to stay on the form itself but does not save the result into database.

function mymodule_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'profile2_edit_main_form'){
    $form['actions']['submit']['#submit'][] ='custom_profile2_edit_submit';

function custom_profile2_edit_submit($form, &$form_state) { 
  $form_state['rebuild'] = TRUE;
  $form_state['redirect'] = REDIRECT_URL;
  drupal_set_message('Changes were saved');

1 Answer 1


I have achieved to make the desired redirection like this:

function redirect_to_edit_form_alter(&$form, &$form_state, $form_id) {
    if ($form_id == "page_article_node_form") {
        //$form['actions']['submit']['#submit'][] = '_redirect_to_edit';
        $form['#action'] = '?destination=node/' . $form['nid']['#value'] . '/edit';

Reference: https://www.drupal.org/node/1074616#comment-5115792

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.