Embed Snippet on Your Site
MemberPress: Restrict Signups to a Specific Country
This code snippet limits registration to users from the specified country only. If users from other countries try to register, an error message will be displayed.
The sample code will restrict registration to users from the United Kingdom, while all other users will encounter the error message "Sorry, signups are currently limited to the UK only."
The code snippet should be updated to adjust it to the needed country. To change the country, the two-letter code (Alpha-2 code) for the United Kingdom (GB) in the sample code should be changed to the two-letter code of the desired country. The two-letter country code should be updated on this line:
$_POST['mepr-address-country'] != 'GB' ) {
The two-letter country ISO codes (Alpha-2 code) are available here.
To modify the error message, edit the text on the following line:
$errors[] = 'Sorry, signups are currently limited to UK only.';
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
Comments