Skip to content

Instantly share code, notes, and snippets.

@ronalfy
Created May 28, 2020 12:42
Show Gist options
  • Save ronalfy/7333859945349b2234b7c3b0cb59bc1c to your computer and use it in GitHub Desktop.
Save ronalfy/7333859945349b2234b7c3b0cb59bc1c to your computer and use it in GitHub Desktop.
Paid Memberships Pro - Ban Email Domains
<?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