This code is a variation of an mu-plugin
Jason wrote to create an email whitelist here.
Create a document called s2-blacklist-email-domains.php
and then copy and paste the following content into it:
<?php
add_filter('ws_plugin__s2member_pro_paypal_form_submission_validation_response', 'blacklist_email_domains', 10, 3);
add_filter('ws_plugin__s2member_pro_stripe_form_submission_validation_response', 'blacklist_email_domains', 10, 3);
function blacklist_email_domains($response, $form, $s)
{
$blacklist = array(
'gmail.com',
'yahoo.com',
'hotmail.com',
);
if(!$response) // No other errors produced by s2Member itself?
if($form === 'registration' || !is_user_logged_in()) // Any new registration, or any new user completing checkout.
{
$domain = ''; // Initialize.
if(isset($s['email']) && strpos((string)$s['email'], '@') !== FALSE)
list(, $domain) = explode('@', (string)$s['email'], 2);
if(!$domain || in_array(strtolower($domain), array_map('strtolower', $blacklist), TRUE))
$response = array(
'error' => TRUE, // This is an error.
'response' => _x('ERROR: You cannot use a personal email account.', 's2member-front', 's2member'),
);
}
return $response; // Always return the filtered response.
}
Now upload that file to your /wp-content/mu-plugins
folder. If you don’t have such a folder, create it. Apart from adding to or otherwise modifying the blacklist as desired, you should now be good to go.