# Block IP Addresses From Fluent Forms

> Stops Fluent Forms submissions from IP addresses or ranges you list, such as a persistent spammer, while they can still read the site.

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

## Code

```php
$wpide_ff_blocked_ips = array( '203.0.113.7', '198.51.100.' );

add_filter( 'fluentform/validation_errors', function ( $errors ) use ( $wpide_ff_blocked_ips ) {
    $ip = isset( $_SERVER['REMOTE_ADDR'] ) ? sanitize_text_field( wp_unslash( $_SERVER['REMOTE_ADDR'] ) ) : '';

    foreach ( $wpide_ff_blocked_ips as $blocked ) {
        $prefix = in_array( substr( $blocked, -1 ), array( '.', ':' ), true );
        if ( $ip === $blocked || ( $prefix && 0 === strpos( $ip, $blocked ) ) ) {
            $errors['_wpide_blocked'] = array( 'Submissions from your network are not accepted.' );
            break;
        }
    }

    return $errors;
}, 5 );
```

## Notes

Use exact addresses, or prefixes ending in a dot or colon for ranges.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Block IP Addresses From 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/
