# Paid Memberships Pro: Restrict Checkout to Certain Email Domains

> Only lets people check out with an email address from your allowed domains, for company, school or association memberships.

- Type: PHP
- Runs: Run everywhere
- Category: [Memberships](https://wpide.com/library/category/memberships/)
- Tags: pmpro, checkout, email
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/pmpro-checkout-email-domains/

## Code

```php
if ( ! function_exists( 'pmpro_setMessage' ) ) {
    return;
}

$wpide_pmpro_allowed_domains = array( 'example.com' );

add_filter( 'pmpro_registration_checks', function ( $continue ) use ( $wpide_pmpro_allowed_domains ) {
    if ( ! $continue ) {
        return $continue;
    }

    $email  = is_user_logged_in() ? wp_get_current_user()->user_email : ( isset( $_REQUEST['bemail'] ) ? sanitize_email( wp_unslash( $_REQUEST['bemail'] ) ) : '' );
    $domain = strtolower( substr( strrchr( $email, '@' ), 1 ) );

    if ( in_array( $domain, $wpide_pmpro_allowed_domains, true ) ) {
        return $continue;
    }

    pmpro_setMessage( sprintf( 'Please use your %s email address to join.', implode( ' or ', $wpide_pmpro_allowed_domains ) ), 'pmpro_error' );

    return false;
} );
```

## Notes

Existing members checking out while logged in are checked against their account email.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Paid Memberships Pro: Restrict Checkout to Certain Email Domains" 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/
