Embed Snippet on Your Site
MemberPress: Restrict Email Patterns for Specific Memberships
This code snippet prevents users with specific email patterns from registering for any of the specified memberships.
When a user attempts to register with a restricted email pattern for a specified membership, the “Email addresses containing certain patterns are not allowed for this plan” error message will be displayed, preventing the registration from completing.
The code snippet should be updated by replacing the dummy membership IDs of 123 and 456 with the IDs of actual memberships, in this line:
$restricted_plan_ids = array(123, 456);
The sample list of specific email patterns ('xxx@gmail', 'xyz@', 'test@test') should be replaced with the actual patterns which should be restricted, in this line:
// Define the patterns to search for in email addresses
$blocked_email_patterns = array('xxx@gmail', 'xyz@', 'test@test');
To edit the error message, modify the "Email addresses containing certain patterns are not allowed for this plan," text in this line:
$errors[] = 'Email addresses containing certain patterns are not allowed for this plan.';
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
Comments