WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How can I access $_POST data after a page redirect?

I guess there is some way to tell WordPress to pass all $_POST data to the redirected address, like it does with $_GET data, using Rewrite Rules, but how?

share|improve this question
up vote 3 down vote accepted

Redirects are GET requests usually, and the browser doesn’t send the POST data for those. That’s not something WordPress can change.

You could create a session, or – better – process the POST data first, then redirect. In your plugin, you could do:

add_action( 'plugins_loaded', 'process_post_data', 0 );

function process_post_data()
    // Read raw POST data, not touched by WordPress
    $data = file_get_contents( 'php://input' );

    // then redirect
share|improve this answer
That's fine, where I can hook a function to get the $_POST data in Wordpress before redirect? – Archedius Apr 30 '13 at 8:51
@Archedius See my update. – toscho Apr 30 '13 at 8:57
That answers my question. It doesn't work with Rewrite Rules though, I have to analyze the URL without rewriting then redirect at Template Redirect, I think. – Archedius Apr 30 '13 at 9:18
@Archedius Internal redirect (no URL change) are fine. Redirects for the browser (to a new URL) should come after POST data processing. – toscho Apr 30 '13 at 9:20

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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