Save custom GET parameters on POST request in WordPress
I need my custom parameter to receive via ANY form submit in WordPress. For example I have post editing like / wp -admin / post.php? Post = 493 & action = edit & foo = bar Then I click update and left, there is no foo in the url.
Did I even add? foo = bar for action = 'post.php' and still nothing. I also added foo to public query_vars. I searched a lot and didn't find anything related to this issue. Is there a way to do what I want? I can use javascript / jquery to manipulate forms.
source to share
I see that you solved the problem with help $_SESSION
, however for those who need such a function and cannot use the session for whatever reason, this is also an option:
<form action="post.php?<?= http_build_query($_GET); ?>">
It looks a little ugly, but it will duplicate any _GET parameters in action.
To test it, I made this slightly awful way to put 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 multiple times before it starts appearing in the url as the first transmission is in POST
, which is then added in GET
the second post. (It will always look behind, but if you look at the html it will be correct).
Final note: All parameters sent via get, post and / or cookie are available in $_REQUEST
.
source to share