Anti-spam honeypots are perhaps the best way to guard your forms from spam submissions. By default Gravity Forms does not add a honeypot to your form; you have to check the appropriate box on the Forms Settings page. However, if you want to enforce anti-spam honeypots on all Gravity forms then you can add this simple snippet. Warning: this function overrides the anti-spam checkbox setting for all your forms.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Enforce anti-spam honeypot on all Gravity forms. | |
* | |
* @param array $form | |
* | |
* @return array $form | |
*/ | |
add_filter( 'gform_form_post_get_meta', function ( $form ) { | |
$form['enableHoneypot'] = true; | |
return $form; | |
} ); |
Leave a Reply