Created
January 13, 2022 15:49
-
-
Save DumahX/fd4fb4474af8518ff6b4ea9ad2063eef to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function mepr_restrict_email_domains($errors) { | |
# Allowed email domains. | |
$allowed_email_domains = array('gmail.com', 'hotmail.com'); | |
$email_address = isset($_POST['user_email']) ? trim($_POST['user_email']) : ''; | |
# Don't bother validating if the email is empty. | |
if(empty($email_address)) { | |
return $errors; | |
} | |
$user_email_array = explode('@', $email_address); | |
$user_email_domain = array_pop($user_email_array); | |
# Check if the user's email domain is allowed. | |
if(!in_array($user_email_domain, $allowed_email_domains)) { | |
$errors[] = 'Your email domain is blocked from signing up.'; | |
return $errors; | |
} | |
return $errors; | |
} | |
add_filter('mepr-validate-signup', 'mepr_restrict_email_domains'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment