# Block Fluent Forms Messages Containing Spam Words

> Stops Fluent Forms submissions when any text field contains a word or phrase from your block list, such as SEO offers or crypto pitches.

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

## Code

```php
$wpide_ff_spam_words = array( 'seo services', 'backlinks', 'crypto', 'casino', 'guest post', 'rank your website' );

add_filter( 'fluentform/validation_errors', function ( $errors, $data ) use ( $wpide_ff_spam_words ) {
    foreach ( (array) $data as $name => $value ) {
        if ( ! is_string( $value ) || 0 === strpos( (string) $name, '_' ) ) {
            continue;
        }

        foreach ( $wpide_ff_spam_words as $word ) {
            if ( preg_match( '/\b' . preg_quote( $word, '/' ) . '\b/iu', $value ) ) {
                $errors[ $name ] = array( 'Your message contains words we do not accept.' );
                return $errors;
            }
        }
    }

    return $errors;
}, 10, 2 );
```

## Notes

The error is shown on the first text field that contains a blocked word; matching is case-insensitive on whole words.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Block Fluent Forms Messages Containing Spam Words" 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/
