Last active
February 3, 2022 17:32
-
-
Save DumahX/35bc4f653a2838d265f058741b64cd87 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_validate_emails_signup($errors) { | |
$allowed_words = array('university'); // ADD ALLOWED WORDS HERE SEPARATED BY COMMAS. | |
$email = isset($_POST['user_email']) ? trim($_POST['user_email']) : ''; | |
$is_allowed = false; | |
// If email is empty for some reason or the membership shouldn't be validated, then just don't do anything. | |
if($_POST['mepr_product_id'] != 123 || empty($email)) { | |
return $errors; | |
} | |
// Loop over allowed words. | |
foreach($allowed_words as $allowed_word) { | |
if(strpos($email, $allowed_word) !== false) { | |
$is_allowed = true; | |
} | |
} | |
if(!$is_allowed) { | |
$errors[] = 'Your email isn\'t allowed to sign up.'; | |
} | |
return $errors; | |
} | |
add_filter('mepr-validate-signup', 'mepr_validate_emails_signup'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment