Created
December 21, 2015 18:43
-
-
Save cartpauj/2c37fd3fbbec9509b916 to your computer and use it in GitHub Desktop.
Limit signups on a particular Membership by email domain
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 ends_with($haystack, $needle = '.ac.uk') { | |
return (($temp = strlen($haystack) - strlen($needle)) >= 0 && strpos($haystack, $needle, $temp) !== FALSE); | |
} | |
function check_email_domain($errors) { | |
$membership_id = 123; //Change this to reflect your Membership ID | |
if($membership_id != $_POST['mepr_product_id']) { | |
return $errors; | |
} | |
$email = stripslashes($_POST['user_email']); | |
if(!ends_with($email)) { | |
$errors[] = "Sorry, only valid .ac.uk email addresses are allowed on this Membership"; | |
} | |
return $errors; | |
} | |
add_filter('mepr-validate-signup', 'check_email_domain'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment