# Use the Comment Blocklist for Fluent Forms

> Blocks Fluent Forms submissions that contain any word, IP address or email from WordPress's Disallowed Comment Keys list, so one blocklist protects comments and forms.

- 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-disallowed-keys-spam/

## Code

```php
add_filter( 'fluentform/validation_errors', function ( $errors, $data ) {
    $keys = trim( (string) get_option( 'disallowed_keys' ) );

    if ( '' === $keys ) {
        return $errors;
    }

    $text = isset( $_SERVER['REMOTE_ADDR'] ) ? sanitize_text_field( wp_unslash( $_SERVER['REMOTE_ADDR'] ) ) : '';
    foreach ( (array) $data as $name => $value ) {
        if ( 0 !== strpos( (string) $name, '_' ) ) {
            $text .= ' ' . ( is_array( $value ) ? implode( ' ', array_filter( $value, 'is_scalar' ) ) : (string) $value );
        }
    }

    foreach ( preg_split( '/\R/', $keys ) as $word ) {
        $word = trim( $word );
        if ( '' !== $word && false !== stripos( $text, $word ) ) {
            $errors['_wpide_blocklist'] = array( 'Your submission could not be accepted.' );
            break;
        }
    }

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

## Notes

Manage the list under Settings > Discussion > Disallowed Comment Keys, one entry per line.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Use the Comment Blocklist for Fluent Forms" 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/
