Skip to content

Instantly share code, notes, and snippets.

@DumahX
Created July 6, 2022 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DumahX/e642eb6850e945abeb5b983621e32360 to your computer and use it in GitHub Desktop.
Save DumahX/e642eb6850e945abeb5b983621e32360 to your computer and use it in GitHub Desktop.
Restrict MemberPress signups by a member's email address.
<?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