# Bricks Forms: Require a Business Email Address

> Rejects Bricks form submissions that use free email providers such as Gmail or Outlook, for B2B quote and demo request forms.

- Type: PHP
- Runs: Run everywhere
- Category: [Page Builders & Themes](https://wpide.com/library/category/page-builders/)
- Tags: bricks, forms, validation, email
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/bricks-form-business-email/

## Code

```php
// Free email domains to refuse, and the error shown.
$wpide_bricks_free_domains = array( 'gmail.com', 'googlemail.com', 'yahoo.com', 'hotmail.com', 'outlook.com', 'live.com', 'aol.com', 'icloud.com', 'gmx.com', 'proton.me' );
$wpide_bricks_free_message = 'Please use your work email address.';

add_filter( 'bricks/form/validate', function ( $errors, $form ) use ( $wpide_bricks_free_domains, $wpide_bricks_free_message ) {
    if ( ! is_object( $form ) || ! method_exists( $form, 'get_fields' ) ) {
        return $errors;
    }

    foreach ( (array) $form->get_fields() as $key => $value ) {
        if ( 0 !== strpos( (string) $key, 'form-field-' ) || ! is_string( $value ) || ! is_email( $value ) ) {
            continue;
        }

        $domain = strtolower( substr( strrchr( $value, '@' ), 1 ) );

        if ( in_array( $domain, $wpide_bricks_free_domains, true ) ) {
            $errors[] = $wpide_bricks_free_message;
            break;
        }
    }

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

## Notes

Checks every email field of every Bricks form. Edit the domain list to suit your audience.

## How to use it

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