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?
1 Answer
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
}