# Require a Work Email in Fluent Forms

> Asks for a company email address instead of Gmail, Yahoo or other free webmail in Fluent Forms, so B2B forms bring in qualified leads.

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

## Code

```php
$wpide_ff_work_forms      = array();           // Form IDs; empty = all forms.
$wpide_ff_work_field      = 'email';           // Email field name.
$wpide_ff_free_providers  = array( 'gmail.com', 'googlemail.com', 'yahoo.com', 'hotmail.com', 'outlook.com', 'live.com', 'aol.com', 'icloud.com', 'gmx.com', 'proton.me', 'protonmail.com', 'mail.com', 'yandex.com' );

add_filter( 'fluentform/validation_errors', function ( $errors, $data, $form ) use ( $wpide_ff_work_forms, $wpide_ff_work_field, $wpide_ff_free_providers ) {
    if ( $wpide_ff_work_forms && ! in_array( (int) $form->id, array_map( 'intval', $wpide_ff_work_forms ), true ) ) {
        return $errors;
    }

    $email  = isset( $data[ $wpide_ff_work_field ] ) && is_string( $data[ $wpide_ff_work_field ] ) ? strtolower( trim( $data[ $wpide_ff_work_field ] ) ) : '';
    $domain = (string) substr( strrchr( $email, '@' ), 1 );

    if ( $domain && in_array( $domain, $wpide_ff_free_providers, true ) ) {
        $errors[ $wpide_ff_work_field ] = array( 'Please use your work email address.' );
    }

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

## Notes

Limit it to forms in the list at the top; the field named "email" is checked unless you change it.

## How to use it

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