The gform_abort_submission_with_confirmation filter determines if submissions are aborted without saving the entry, processing add-on feeds, or sending notifications.
Usage
A generic example for all forms:
add_filter( 'gform_abort_submission_with_confirmation', 'your_function_name', 10, 2 );
For a specific form with form ID 6:
add_filter( 'gform_abort_submission_with_confirmation_6', 'your_function_name', 10, 2 );
Parameters
- $do_abort (boolean): Indicates if the submission should abort without saving the entry. Default is
false
. Will betrue
if the anti-spam honeypot is enabled and the honeypot identified the submission as spam. - $form (Form Object): The form currently being processed.
More information
See Gravity Forms Docs: gform_abort_submission_with_confirmation
This filter was added in Gravity Forms v2.7. It is located in GFFormDisplay::process_form() in form_display.php
.
Examples
Check a field value
Abort the submission if input 1 contains ‘i am a spam’.
add_filter( 'gform_abort_submission_with_confirmation', function( $do_abort ) { if ( $do_abort ) { return true; } $is_spam = strpos( rgpost( 'input_1' ), 'i am a spam' ) !== false; return $is_spam; });
Run anti-spam checks before entry save
Run anti-spam checks, such as Akismet, before the entry has been saved. This will also trigger the gform_entry_is_spam
filter.
add_filter( 'gform_abort_submission_with_confirmation', 'abort_gf_submission_if_spam', 10, 2 ); function abort_gf_submission_if_spam( $do_abort, $form ) { if ( $do_abort ) { return true; } $entry = GFFormsModel::get_current_lead(); return GFCommon::is_spam_entry( $entry, $form ); }