# Block Email Domains in Fluent Forms

> Shows an error when someone uses an email address from a domain on your block list, such as throwaway inbox services, in a Fluent Forms form.

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

## Code

```php
$wpide_ff_email_fields     = array( 'email' ); // Email field names to check.
$wpide_ff_blocked_domains  = array( 'mailinator.com', 'yopmail.com', 'tempmail.com', 'guerrillamail.com', 'sharklasers.com' );

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

        $domain = strtolower( (string) substr( strrchr( trim( $data[ $name ] ), '@' ), 1 ) );

        foreach ( $wpide_ff_blocked_domains as $blocked ) {
            if ( $domain && ( $domain === $blocked || substr( $domain, -strlen( '.' . $blocked ) ) === '.' . $blocked ) ) {
                $errors[ $name ] = array( 'Please use a different email address.' );
                break;
            }
        }
    }

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

## Notes

Needs Fluent Forms 5.0 or later and checks the field named "email" unless you list other email field names at the top.

## How to use it

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