diff --git a/inc/cleantalk-public-integrations.php b/inc/cleantalk-public-integrations.php index 92be87b6b..33e9a6b7c 100644 --- a/inc/cleantalk-public-integrations.php +++ b/inc/cleantalk-public-integrations.php @@ -2693,6 +2693,7 @@ function apbct_form__gravityForms__addField($form_string, $form) * Gravity forms anti-spam test. * @return boolean * @psalm-suppress UnusedVariable + * @psalm-suppress ArgumentTypeCoercion */ function apbct_form__gravityForms__testSpam($is_spam, $form, $entry) { @@ -2825,7 +2826,12 @@ function apbct_form__gravityForms__testSpam($is_spam, $form, $entry) $is_spam = true; $ct_gform_is_spam = true; $ct_gform_response = $ct_result->comment; - add_action('gform_entry_created', 'apbct_form__gravityForms__add_entry_note'); + if ( isset($apbct->settings['forms__gravityforms_save_spam']) && $apbct->settings['forms__gravityforms_save_spam'] == 1 ) { + add_action('gform_entry_created', 'apbct_form__gravityForms__add_entry_note'); + } elseif ( class_exists('GFFormsModel') && method_exists('GFFormsModel', 'delete_lead') ) { + /** @psalm-suppress UndefinedClass */ + GFFormsModel::delete_lead($entry['id']); + } } } diff --git a/inc/cleantalk-settings.php b/inc/cleantalk-settings.php index bdd9c7f89..0cfc5f900 100644 --- a/inc/cleantalk-settings.php +++ b/inc/cleantalk-settings.php @@ -231,6 +231,16 @@ function apbct_settings__set_fields() 'parent' => 'forms__contact_forms_test', 'display' => apbct_is_plugin_active('contact-form-7/wp-contact-form-7.php') && apbct_is_plugin_active('flamingo/flamingo.php'), ), + 'forms__gravityforms_save_spam' => array( + 'title' => __('Save Gravity Forms spam entries', 'cleantalk-spam-protect'), + 'description' => __( + 'Spam Gravity Forms entries will be saved into Gravity Forms spam entries if the option is enabled', + 'cleantalk-spam-protect' + ), + 'class' => 'apbct_settings-field_wrapper--sub', + 'parent' => 'forms__contact_forms_test', + 'display' => apbct_is_plugin_active('gravityforms/gravityforms.php'), + ), 'forms__general_contact_forms_test' => array( 'title' => __('Custom contact forms', 'cleantalk-spam-protect'), 'description' => __( diff --git a/inc/cleantalk-updater.php b/inc/cleantalk-updater.php index 7ce5e2a73..f22576d32 100644 --- a/inc/cleantalk-updater.php +++ b/inc/cleantalk-updater.php @@ -1314,5 +1314,13 @@ function apbct_update_to_6_54_1() $apbct->settings['data__email_decoder_encode_email_addresses'] = 0; } + if ( ! isset($apbct->settings['forms__gravityforms_save_spam']) ) { + $apbct->settings['forms__gravityforms_save_spam'] = + isset($apbct->default_settings['forms__gravityforms_save_spam']) + ? $apbct->default_settings['forms__gravityforms_save_spam'] + : 1; + $apbct->saveSettings(); + } + $apbct->saveSettings(); } diff --git a/lib/Cleantalk/ApbctWP/State.php b/lib/Cleantalk/ApbctWP/State.php index fb980054c..9a97d49e9 100644 --- a/lib/Cleantalk/ApbctWP/State.php +++ b/lib/Cleantalk/ApbctWP/State.php @@ -51,6 +51,7 @@ class State extends \Cleantalk\Common\State 'forms__comments_test' => 1, 'forms__contact_forms_test' => 1, 'forms__flamingo_save_spam' => 1, + 'forms__gravityforms_save_spam' => 1, 'forms__general_contact_forms_test' => 1, // Anti-Spam test for unsupported and untested contact forms 'forms__wc_checkout_test' => 1, // WooCommerce checkout default test 'forms__wc_register_from_order' => 1, // Woocommerce registration during checkout