Last active
July 16, 2019 14:00
-
-
Save cartpauj/897ba2ab5dd7626861a80c75ff02b22a to your computer and use it in GitHub Desktop.
Limit MemberPress Signups to one Country
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 limit_signups_to_one_country($errors) { | |
// Limit Signups to USA only | |
if(!isset($_POST['mepr-address-country']) || $_POST['mepr-address-country'] != 'US') { | |
$errors[] = 'Sorry, signups are currently limited to USA only.'; | |
} | |
return $errors; | |
} | |
add_filter('mepr-validate-signup', 'limit_signups_to_one_country'); |
Removes countries from dropdown itself.
function filter_out_countries($countries, $prioritize_my_country) {
$countries_to_keep = array('AU', 'NZ');
foreach($countries as $code => $title) {
if( ! in_array($code, $countries_to_keep) ) {
unset($countries[$code]);
}
}
return $countries;
}
add_filter('mepr_countries', 'filter_out_countries', 11, 2);
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Multiple countries example