Black Friday Super Sale! 🔥 Enjoy a jaw-dropping discount of up to 50% OFF on all Nextend Social Login plans. Hurry, the offer ends on December 3rd!
Buy now

How to prevent registration with certain email domains?

You can either allow or prevent registration with certain email domains using the nsl_registration_user_data filter.

Example

Disable registration with the gmail.com email domain:

Code
add_filter('nsl_registration_user_data', function ($user_data, $provider, $errors) {
    /**
     * List of banned domains. Multiple domains can be separated with commas e.g.: "gmail.com","yahoo.com"
     */
    $banned_domains = array("gmail.com");
    if (isset($user_data['email']) && !empty($user_data['email']) && is_email($user_data['email'])) {
        $email_parts = explode('@', $user_data['email']);
        if (in_array($email_parts[1], $banned_domains )) {
            /**
            * The error message.
            */
            $errors->add('invalid_email', '' . __('ERROR') . ': ' . __('Sorry, registration with this email domain is not allowed!'));
            return $user_data;
        }
    } else {
        $errors->add('invalid_email', '' . __('ERROR') . ': ' . __('Sorry, email is missing or invalid!'));
    }

    return $user_data;
}, 10, 3);

Available since: 3.0.20

🍪 We use cookies!

We use cookies to enhance your browsing experience, serve personalized content, and analyze our traffic. By clicking "Accept All", you consent to our use of cookies. You can manage your preferences or learn more in our Cookie Policy.

Accept all
Reject all
Cookie Policy