• Resolved PaulH

    (@paulhuckstepp)


    Is it possible from within the form/submission filter:

    add_action( ‘af/form/submission’, ‘processFormData’, 10, 3 );

    To tell ACF Form to display an error message instead of the success message?

    I’ve looked through the documentation but that only seems to apply validation errors to fields (or the entire form). I want to use the submission filter to process the form fields and then block the final submission (already done) and show a failure message instead of the usual Success message.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author fabianlindfors

    (@fabianlindfors)

    Hey, Paul!

    Technically there is an undocumented action called af/form/before_submission from which you can call af_add_submission_error( $message ) to add an error and stop the submission. There isn’t an easy way to do it from the actual af/form/submission action though.

    May I ask what your needs are which means the af/form/validate action won’t work?

    Thread Starter PaulH

    (@paulhuckstepp)

    I have a large function in af/form/submission that goes though all the fields submitted and runs a custom spam check through. If it finds the submission was spam the function it prevents the email notification from sending and stores the entry id in a list so that it can be automatically deleted later on. After this the page refreshes and shows the Success message.

    Generally this is OK. But I was hoping I might be able to trigger something at this late stage to tell the plugin to display a submission error message instead.

    The reason I’m not doing this as part of a validation is so that the user is forced to actually submit the form correctly first (which cuts out a lot of spam) and then prevent the spam message using more extreme filters.

    Plugin Author fabianlindfors

    (@fabianlindfors)

    In that case, af/form/before_submission might work as it’s run after validation but before any processing (so you won’t need to delete the entry later). It’s highly untested though so I can’t guarantee that it will work. If you find some bug, I’d be happy to fix it!

    Thread Starter PaulH

    (@paulhuckstepp)

    Ok, thank you. I will give it a try and see what happens.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Submission Failed Notice’ is closed to new replies.