Halloween Sale 15% off Ends in See the plans
PHP

Turn On the Gravity Forms Honeypot for Every Form

Switches on Gravity Forms' built-in anti-spam honeypot for all forms, including ones created later, so nobody has to remember the setting.

Don’t have WPIDE yet? Install it on your site

Code

$wpide_gf_honeypot_skip = array(); // Form IDs to leave alone.

add_filter( 'gform_form_post_get_meta', function ( $form ) use ( $wpide_gf_honeypot_skip ) {
    if ( is_array( $form ) && ! in_array( (int) rgar( $form, 'id' ), array_map( 'intval', $wpide_gf_honeypot_skip ), true ) ) {
        $form['enableHoneypot'] = true;
    }

    return $form;
} );

Notes

Exclude a form by adding its ID to the list at the top.

How to add this snippet

  1. Install WPIDE on your WordPress site (it is free) and open Code Snippets.
  2. Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
  3. It is added inactive: review the code and settings, then switch it on.

Have a snippet worth sharing?

Publish it to the library from WPIDE or right here. Sign in with any WordPress site that runs WPIDE, free or Pro. Public snippets are reviewed by the WPIDE team before they appear.

Which site should get this snippet?

Enter the address of your WordPress site. WPIDE opens there in a new tab with the snippet ready to review and save.

Remembered in this browser only, so you are asked once.

Report this snippet

Tell the WPIDE team what is wrong: broken code, something harmful, spam or copied work.