I have a privatemsg message form, and I need to alter the success URL that loads when a message is sent. What is the easiest way to go about doing this? The code i'm using is more or less based on the example code used here:

 print drupal_render(drupal_get_form('privatemsg_new'));

Using the Devel module implement hook_form_alter and find your forms $form_id. Then supply a #redirect FAPI attribute like, $form['#redirect'] = 'my-custom-thankyou-page'; and be sure to make your custom page as a drupal Page, module callback, View etc.

  • I've set the redirect in question using hook_form_FORM_ID_alter through a module, and its still not functional. The module in question is one used to display a variety of pages pertaining to user information, and has a template that explicitly references the above privatemsg form function example_user_form_privatemsg_new_alter(&$form, &$form_state) { $form['#redirect'] = "classes"; $form_state['redirect'] = 'classes'; } – Cameron Kilgore Jul 20 '12 at 21:04

Your Answer

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

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