# Mark Gravity Forms Entries With Spam Words as Spam

> Sends Gravity Forms entries to the Spam list when any field contains a word or phrase from your block list, so they skip notifications and stay out of your entries.

- Type: PHP
- Runs: Run everywhere
- Category: [Forms](https://wpide.com/library/category/forms/)
- Tags: gravity-forms, spam, blocklist
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/gf-blocked-words-spam/

## Code

```php
$wpide_gf_spam_words = array( 'seo services', 'backlinks', 'crypto', 'casino', 'guest post', 'web design offer', 'loan' );

add_filter( 'gform_entry_is_spam', function ( $is_spam, $form, $entry ) use ( $wpide_gf_spam_words ) {
    if ( $is_spam ) {
        return $is_spam;
    }

    $text = '';
    foreach ( $form['fields'] as $field ) {
        $text .= ' ' . (string) $field->get_value_export( $entry );
    }

    foreach ( $wpide_gf_spam_words as $word ) {
        if ( preg_match( '/\b' . preg_quote( $word, '/' ) . '\b/iu', $text ) ) {
            if ( method_exists( 'GFCommon', 'set_spam_filter' ) ) {
                GFCommon::set_spam_filter( rgar( $form, 'id' ), 'WPIDE blocked words', sprintf( 'Contains "%s".', $word ) );
            }
            return true;
        }
    }

    return false;
}, 10, 3 );
```

## Notes

Spam entries can still be reviewed and restored from the form's Spam list; matching is case-insensitive on whole words.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Mark Gravity Forms Entries With Spam Words as Spam" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
