Created
May 28, 2020 12:42
-
-
Save ronalfy/7333859945349b2234b7c3b0cb59bc1c to your computer and use it in GitHub Desktop.
Paid Memberships Pro - Ban Email Domains
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 | |
function pmpro_custom_banned_domains( $continue_registration ) { | |
global $pmpro_msg, $pmpro_msgt; | |
if ( isset ( $_REQUEST['bemail'] ) ) { | |
$bemail = sanitize_email( stripslashes( $_REQUEST['bemail'] ) ); | |
$banned_email_domains = array( | |
'.ru', /* Add more email domains here */ | |
); | |
foreach ( $banned_email_domains as $domain ) { | |
if ( strstr( $bemail, $domain ) ) { | |
$pmpro_msgt = 'pmpro_error'; | |
$pmpro_msg = 'The email you entered is invalid.'; | |
return false; | |
} | |
} | |
} | |
return $continue_registration; | |
} | |
add_filter( 'pmpro_registration_checks', 'pmpro_custom_banned_domains', 10, 1 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment