Created
July 6, 2022 14:05
-
-
Save DumahX/e642eb6850e945abeb5b983621e32360 to your computer and use it in GitHub Desktop.
Restrict MemberPress signups by a member's email address.
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 | |
add_filter('mepr-validate-signup', function($errors) { | |
/* Edit this to add or remove email addresses you'd like to block from registering. | |
For example, if you'd like to block members with the following email addresses: | |
- member@email.com | |
- anothermember@google.com | |
Then the code would look something like this: $email_addresses_to_block = ['member@email.com', 'anothermember@google.com']; | |
*/ | |
$email_addresses_to_block = ['member@email.com']; | |
$user_email = isset($_POST['user_email']) ? trim($_POST['user_email']) : ''; | |
if(empty($user_email)) { | |
return $errors; | |
} | |
if(in_array($user_email, $email_addresses_to_block)) { | |
// Change 'Your email address is not allowed to sign up.' to the error message you'd like displayed | |
// if the email address is blocked. | |
$errors[] = 'Your email address is not allowed to sign up.'; | |
} | |
return $errors; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment