Keep custom GET parameters over POST request in WordPress
I see that you've solved the issue using $_SESSION
however for anyone else that needs this sort of functionality and can't use the session for any reason, this is also an option:
<form action="post.php?<?= http_build_query($_GET); ?>">
It looks a bit ugly, but it'll repeat any _GET parameters into the action.
To test, I made this slightly awful way of tacking everything together:
<form method="post" action="?<?= http_build_query($_GET);?>&<?= http_build_query($_POST);?>"> <label> Test<input name="<?= time() ?>"></label></form>
Note: You have to submit a few times before it starts appearing in the url as first submission is in POST
, which is then added to the GET
in the second post. (It'll always look like it's one behind, but if you look at the html it'll be right).
Final note: All parameters sent via get, post and/or cookie, are available in $_REQUEST
.