Support

Account

Home Forums ACF PRO Validation problems Front End Ajax ACF => 5.5

Solved

Validation problems Front End Ajax ACF => 5.5

  • Hello everyone

    I have been working actively to find a definitive solution for using ACF in the front end through Ajax (Download the feature test theme – https://goo.gl/sB3IMZ).

    In general, things work well, but:

    Until version ACF5.4.8 when calling ‘acf / validate_save_post’ received an array with fields with validation failures (object->data->errors->0->[input, message], But in versions after> 5.5.x I only get the error message already in html and not the name of the fields (name, attr, id or class) that allows me to change the color of the fields with error

    Does anyone have an idea how to get the identifier of the fields with error?

  • Hi @felipeost

    I’ve just checked your theme, but couldn’t find the code that uses the acf/validate_save_post hook. Could you please share the code so I can test in on my installation?

    Also, could you please share the JSON or XML export file of your field group?

    Thanks 🙂

  • I’m having what I think is a similar issue with ACF PRO versions >= 5.5.0.

    At present, I have front-end ajax submission forms that work well with ACF PRO 5.4.8. On the js end, the script first checks for validation errors via the acf/validate_save_post action, and if the returned object from that call includes data.valid: 1 I go on to call an action attached to acf_form_head that updates field values.

    However, with versions >= 5.5.0, no data/object is returned from my first acf/validate_save_post call.

    Here’s an example of an object that’s getting sent to acf/validate_save_post in my jquery ajax call:

    
    {
      acf[_validate_email]:"",
      acf[field_5745dbdfc7e0b]:"Foo Bar",
      action:"acf/validate_save_post",
      _acfchanged:"1",
      _acfform:"Mm0rU0VT[abbreviated]",
      _acfnonce:"7ba82c905c"
    }
    

    And here’s the response that call gets using ACF PRO < 5.5.0:

    
    {
      data:{
        errors:0,
        valid:1
      },
      success: true
    }
    

    Any ideas about why I’m no longer getting a response to this call would be very much appreciated!!!

    Thanks,
    Ethan

  • ACF Pro Version 5.5.14, Front-end AJAX Form Validation is not working, form submission redirect to a page and display the error message. It doesn’t display the error message within the form.
    Thanks
    -Eesan

  • Hi,

    after a long time, I found what I think be a solution

    in core/validation.php line 158 change:

    if( !acf_verify_ajax() ) die();

    to

    if( acf_verify_ajax() ) die();

    this solve my question, but updates concern me

  • I have the same problem – felipeosts solution worked for me, but I also worry about updates with this fix. Any permanent solution would be appreciated. Thanks!

  • I have the same problem, the validation in the backend does not work anymore. it works with the fix, we urgently need a solution.

  • I also ran into a similar problem where the ajax validation had mysteriously stopped working, then come back, then stopped working again. The if( !acf_verify_ajax() ) die(); tip above helped me narrow it down to a wp_verify_nonce() fail inside that function, which apparently was due to the admin being forced over https when the front end form was still over http. I’m not sure this would solve the original poster’s issue, but for anyone who had the ajax validation mysteriously disappear on them, I would suggest trying to load the form over https if the admin is forced over https.

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

The topic ‘Validation problems Front End Ajax ACF => 5.5’ is closed to new replies.