Support

Account

Home Forums Front-end Issues Validation runs twice

Helping

Validation runs twice

  • I’m trying to create a custom ReCaptcha V3 response. Everything is running smooth, but when I’m running code through acf/validate_save_post, it prints the output twice.

    I’m testing this with:

    function recaptcha_server_response() {
    
    error_log(print_r( 'output test', true ));
    
    }
    add_action('acf/validate_save_post', 'recaptcha_server_response', 10, 0);

    The output in my error log:

    [04-May-2019 12:55:55 UTC] test
    [04-May-2019 12:56:41 UTC] test

    I’ve disabled all plugins (except ACF) and removed all custom code. Am I doing something wrong, or is there an obvious explanation?

  • If I am not mistaken, this hook is fired twice. Once during the AJAX validation phase and then again when the post is submitted. To confirm this you could output the value of DOING_AJAX and see if it is different for each request.

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

The topic ‘Validation runs twice’ is closed to new replies.