0

I am unable to redirect back to the page after executing the user_save. Following is my code snippet:

//if the response code is failed rollback the user changes and redirect
if ($results['code']!=200) {
  user_save(NULL,$account);
  drupal_goto("/admin/people");
} 
4
  • what does user_save() return? can you try to put an echo statement after user_save()?
    – Vimalnath
    Commented Apr 12, 2013 at 7:32
  • Are you working on your custom module for the same? Commented Apr 12, 2013 at 8:15
  • Thanks develkar. It was my mistake I modified the code user_save(NULL,$edit); Commented Apr 12, 2013 at 8:58
  • @JayeshJose I was about the comment the same thing, but somehow missed it. The second argument to user_save should be an array and not the object. Anyways it is good that you figured it out yourself. Please answer your own question, and accept it after a day so that the question gets out of the unanswered questions list.
    – AjitS
    Commented Apr 12, 2013 at 10:15

1 Answer 1

0

Please check the below format:

function mymodule_form_alter(&$form, $form_state, $form_id) {
  if ($form_id === 'form_id_goes_here') {
    // Code here
    $form['#submit'][] = '_mymodule_test_registration_submit';
  }
}

function _mymodule_test_registration_submit($form, &$form_state) {
  // Code here
  $form_state['redirect'] = 'path1/path2/mypage';
}

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.