How to return variables from admin-post.php
If I submit a form with an action of
/wp-admin/admin-post.php, is there a way to return form errors to the originating page?
My form has an input with the action set:
<input name="action" value="enquiry_form" />
I have an actions setup to manage the validation:
I can return to the original form page with a wp_redirect:
But how can I pass variables/ messages back to this page after redirecting?
To add clarification, I was under the impression this was the “correct” way to handle form data, rather than simply adding an init hoot to check for a specific POST variable. There are countless tutorials where people use the admin-post.php action, for example: