Created
January 12, 2022 06:24
-
-
Save ipokkel/7db4c30cc8bf72e738b09bcf15b4a4e3 to your computer and use it in GitHub Desktop.
Block restricted specific email addresses from checking out for a membership.
This file contains hidden or 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 | |
/** | |
* Exclude specific email domains from membership signup. | |
* Make sure to edit the $invalid_domains array defined further below | |
* to include only the domains you'd like to block. | |
* | |
*/ | |
function block_restricted_email_addresses_pmpro_registration_checks( $value ) { | |
// set array of restricted email addresses. | |
$restricted_emails = array( '[email protected]', '[email protected]' ); | |
// do we have an email to check? | |
if ( ! isset( $_REQUEST['bemail'] ) || empty( $_REQUEST['bemail'] ) ) { | |
return $value; | |
} | |
// get email address | |
$email = $_REQUEST['bemail']; | |
if ( in_array( $email, $restricted_emails ) ) { | |
global $pmpro_msg, $pmpro_msgt; | |
$pmpro_msg = 'Please enter a valid email address'; | |
$pmpro_msgt = 'pmpro_error'; | |
return false; | |
} | |
return $value; | |
} | |
add_filter( 'pmpro_registration_checks', 'block_restricted_email_addresses_pmpro_registration_checks', 10, 1 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To exclude an email domain from checking out see https://www.paidmembershipspro.com/exclude-certain-email-domains-from-membership-signup/