Support

Account

Home Forums ACF PRO ACF Frontend Redirect Issue

Solving

ACF Frontend Redirect Issue

  • Hello

    I am attempting to render ACF forms on the frontend.

    Here is some sample code I am using:

    
    add_action('genesis_entry_content', 'checklist_1_single');
    function checklist_1_single() {
      acf_form();  
    }
    

    (this is in a single-[my-content-type].php template override).

    In functions.php I have the following:

    add_action('init', 'acf_form_head');

    With these two bits of code, the form renders fine.

    However when I submit the form it pushes an AJAX submission to admin.ajax.php which promptly processes the submission and performs a 302 redirect to /my-path??updated=true.

    That’s nice, but this just causes the form to hang. Shouldn’t the AJAX be sending a message back to some callback in ACF to prompt it to send the user to the given return page, rather than simply 302ing the ajax request?

    Also, I tried removing

    add_action('init', 'acf_form_head');

    from functions.php and the submission works, but other things like conditional fields, wysiwyg etc don’t work properly.

    I’m running WordPress 4.2.1 with ACF Pro 5.2.3 on top of Genesis 2.1.2.

    Any assistance appreciated

  • Not sure if you’re still having problems with this, trying to clear up older questions.

    Are you still seeing the problem of the form submission hanging instead of redirecting with the newest version of ACF?
    What browser are you seeing this in?

  • Hi John

    I didn’t wait for an updated version of ACF to solve this issue (I posted the support request nearly 2 months ago).

    Instead I used a workaround in the form of some ACF form overrides, a custom AJAX callback, some ACF actions and some WordPress AJAX actions. This sends its own modified AJAX request to ACF, and some hooks perform some overrides to return JSON objects (for validation and saving respectively) rather than just redirecting. Then I was able to capture that data to do whatever I wanted (in this case displaying a success message rather than redirecting).

    See the following code sample: http://pastebin.com/L55bNyu7

    Cheers

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

The topic ‘ACF Frontend Redirect Issue’ is closed to new replies.