I'm developing a plugin that handles form submissions at several different points. As such, I was relying on being able to use global $post and get_query_var to determine which stage the user is at and handle the submission & redirect accordingly. However, it's become apparent that neither $post nor get_query_var are available at the point init is fired (which is when I've always hooked in for standard form submissions before, and everything I can find online recommends the same).

Without seriously rethinking this whole thing, can I hook into a different, later action (for example wp) to process the form submission and access the required variables? Is there any issue with hooking into a later action like this?

I'm aware that hooking into wp-head is too late if I want to use wp_redirect, and I guess I'd need to hook in to something either at or after parse_request to get access to get_query_vars()?

  • I would look into the template_redirect hook – czerspalace Sep 9 '15 at 19:36
  • @czerspalace Thanks - for the moment I've gone with the wp hook - any particular reason to choose one over the other? Or just dealer's choice? – indextwo Sep 10 '15 at 16:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.