diff --git a/core/CF7_AntiSpam.php b/core/CF7_AntiSpam.php index b8e14b2..1f3c0cc 100644 --- a/core/CF7_AntiSpam.php +++ b/core/CF7_AntiSpam.php @@ -258,6 +258,7 @@ private function load_frontend() { /* It adds hidden fields to the form */ $this->loader->add_filter( 'wpcf7_form_hidden_fields', $plugin_frontend, 'cf7a_add_hidden_fields', 1 ); + $this->loader->add_filter( 'wpcf7_config_validator_available_error_codes', $plugin_frontend, 'cf7a_remove_cf7_error_message', 10, 2 ); /* adds the javascript script to frontend */ $this->loader->add_action( 'wp_footer', $plugin_frontend, 'enqueue_scripts' ); diff --git a/core/CF7_AntiSpam_Frontend.php b/core/CF7_AntiSpam_Frontend.php index 47f04f7..136b68c 100644 --- a/core/CF7_AntiSpam_Frontend.php +++ b/core/CF7_AntiSpam_Frontend.php @@ -61,6 +61,24 @@ public function __construct( $plugin_name, $version ) { $this->options = CF7_AntiSpam::get_options(); } + /** + * Remove "unsafe email config" error messsage + * + * @param array $error_codes List of error codes. + * @param object $contact_form Current contact form object. + * @return array Modified array of error codes, without "unsafe_email_without_protection". + */ + public function cf7a_remove_cf7_error_message( $error_codes, $contact_form ) { + // List error codes to disable here. + $error_codes_to_disable = array( + 'unsafe_email_without_protection', + ); + + $error_codes = array_diff( $error_codes, $error_codes_to_disable ); + + return $error_codes; + } + /** * It takes the form elements, clones the text inputs, adds a class to the cloned inputs, and adds the cloned inputs to the form *