MemberPress: Restrict Signups for US-Based Users

function limit_signups_to_excluded_regions( $errors ) { // Check if the country field is set If ( isset( $_POST[ ‘mepr-address-country’ ] ) ) { $country = sanitize_text_field( wp_unslash( $_POST[ ‘mepr-address-country’ ] ) ); // Exclude EU countries if ( $country == ‘US’…Continue reading

MemberPress: Restrict Signups for EU-Based Users

function limit_signups_to_excluded_regions( $errors ) { // List of EU country codes $eu_countries = array( ‘AT’, ‘BE’, ‘BG’, ‘HR’, ‘CY’, ‘CZ’, ‘DK’, ‘EE’, ‘FI’, ‘FR’, ‘DE’, ‘EL’, ‘HU’, ‘IE’, ‘IT’, ‘LV’, ‘LT’, ‘LU’, ‘MT’, ‘NL’, ‘PL’, ‘PT’, ‘RO’, ‘SK’, ‘SI’, ‘ES’,…Continue reading

MemberPress: Require Coupon Code for Specific Free Memberships

// CHANGE this array – should be a comma separated list of Membership ID’s to apply the signup codes to $GLOBALS[‘free_memberships_require_coupon’] = array(123); function make_coupon_mandatory_free_membership($errors) { if(!isset($_POST[‘mepr_coupon_code’]) || trim($_POST[‘mepr_coupon_code’]) == ” && in_array($_POST[‘mepr_product_id’], $GLOBALS[‘free_memberships_require_coupon’])) { $errors[] = ‘A valid coupon…Continue reading

MemberPress: Restrict Email Patterns for Specific Memberships

function mepr_restrict_email_patterns_for_specific_plans($errors) { // Define the patterns to search for in email addresses $blocked_email_patterns = array( ‘xxx@gmail’, ‘xyz@’, ‘test@test’ ); // Define specific subscription plan IDs that require email restriction $restricted_plan_ids = array( 123, 456 ); // Replace with actual…Continue reading

MemberPress: Restrict Email Patterns for All Memberships

function mepr_restrict_email_patterns_for_all_plans($errors) { // Define the patterns to search for in email addresses $blocked_email_patterns = array( ‘xxx@gmail’, ‘xyz@’, ‘test@test’ ); // Retrieve the email address from the form submission $email_address = isset( $_POST[ ‘user_email’ ] ) ? sanitize_email( trim( $_POST[…Continue reading

MemberPress: Restrict Email Domains on Registration

function mepr_restrict_email_domains($errors) { # Allowed email domains. $allowed_email_domains = array(‘gmail.com’, ‘hotmail.com’); $email_address = isset($_POST[‘user_email’]) ? sanitize_email(trim($_POST[‘user_email’])) : ”; # Don’t bother validating if the email is empty. if(empty($email_address)) { return $errors; } $user_email_array = explode(‘@’, $email_address); $user_email_domain = array_pop($user_email_array); #…Continue reading

MemberPress: Limit Phone Number Digits

function mepr_limit_phone_digits( $errors ) { $phone = isset( $_POST[‘mepr_phone_number’] ) ? sanitize_text_field(trim($_POST[‘mepr_phone_number’])) : ”; // Remove all non-numeric characters from the phone number. $phone = preg_replace(“/[^0-9]/”, “”, $phone); // Check if phone digits equal 11 if (strlen($phone) != 11) {…Continue reading