Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ipokkel/7db4c30cc8bf72e738b09bcf15b4a4e3 to your computer and use it in GitHub Desktop.
Save ipokkel/7db4c30cc8bf72e738b09bcf15b4a4e3 to your computer and use it in GitHub Desktop.
Block restricted specific email addresses from checking out for a membership.
<?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 );
@ipokkel
Copy link
Author

ipokkel commented Jan 12, 2022

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment