For starters, it's a plugin (with a shortcode) or at least I would prefer it to be.

I've got two issues both related to wp_direct.

If form 1 validates I want to redirect to form 2, and continue the process.

If the visitor tries to start at form 2 without first having filled out form 1, then I want to redirect them back to form 1.

I've tried a number of different things and I continue to get "Cannot modify header". Even when the __construct() uses add_action ''send_headers' I still get the header error. How do I validate a form, redirect and then display a second form.

This hardly seems like an advance need. Yet I've spend a good part of the day looking for answers and here I am begging for help :)

Thanks in advance.

p.s. wp_safe_redirect() doesn't show up in the tags list.

  • 1
    You should really add some informations to your question. What code do you have? Where does the forms appear (sidebar, main page, within a post/page). When and where does the 'headers already send' error appear.
    – Ralf912
    Commented Apr 15, 2013 at 1:35

1 Answer 1


You have a form like

<form action="http://some/url/form_two.php" method="POST">
 <input type="whatever" value="nothing" />
 <input type="hidden" name="form_one_displayed" value="1" />
 <input type="submit" value="Send" />

in e.g form_one.php

In form_two.php you validate the data that was send (or not)

$result = do_some_validation_with( $_POST );

if ( false == $result )
  wp_redirect( 'form_one.php' );

function do_some_validation_with( $postdata = array() ) {
  // nothing was send
  if ( empty( $postdata ) )
    return false;

  // if the first form wasn't send, stop validation
  if ( ! isset( $postdata['form_one_displayed'] ) )
    return false;

  // do more validation

  // if validation pass
  return true;

function display_form_two() {}

I think it is easier to use an ajax request to validate the form data and display the second form only if the first one was validated.

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.