Home Forums Front-end Issues Why can't I redirect after form submission?


Why can't I redirect after form submission?

  • I’m working on a plugin that will integrate with ACF to do the following.
    – Display a form on the front end.
    – Get the responses and save them as a new CPT.
    – Redirect the user to a ‘Thank you’ page when submitted.

    The context is that this plugin uses a custom template that’s inside the plugin directory. I’m doing this because when the project is finished, I won’t necessarily have access to the file structure of my sites, but I will be able to load plugins and all the sites use ACF.

    The only thing the template really does is


    This should ensure that I have access to everything ACF needs before the head is called. So, using ACF v4.4.1 I’ve got it where I can use a shortcode e.g. [generate_form submit="foo" redirect="bar"].

    The catch is that the only thing that seems to not work is my redirect. When I submit the form, the same page reloads, but without the form. Why would this not work correctly? Everything else about the plugin and template seem to be working.

    The attached file is most of the code (without the CPT code).

  • Never mind. I solved it. For anyone interested, my template (in the plugin directory) just does


    In my plugin file, I made a function like this

    function load_acf_form_head() { // do things to get the template };
    add_filter('wp_enqueue_scripts', 'load_acf_form_head', 0);

    This seems to change the order the template’s called in.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.