# Block Links in Fluent Forms Messages

> Shows an error when a Fluent Forms message field contains web links, which removes most link spam without a captcha.

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

## Code

```php
$wpide_ff_link_fields = array( 'message', 'description' ); // Field names to check.
$wpide_ff_max_links   = 0;

add_filter( 'fluentform/validation_errors', function ( $errors, $data ) use ( $wpide_ff_link_fields, $wpide_ff_max_links ) {
    foreach ( $wpide_ff_link_fields as $name ) {
        if ( empty( $data[ $name ] ) || ! is_string( $data[ $name ] ) ) {
            continue;
        }

        if ( preg_match_all( '#(https?://|www\.|\[url|<a\s)#i', $data[ $name ] ) > $wpide_ff_max_links ) {
            $errors[ $name ] = array( 'Please remove the links from your message.' );
        }
    }

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

## Notes

List the names of the fields to check at the top; the default is the "message" field.

## How to use it

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