Skip to content

Instantly share code, notes, and snippets.

@alexschreyer
Last active December 14, 2015 06:18
Show Gist options
  • Save alexschreyer/5041216 to your computer and use it in GitHub Desktop.
Save alexschreyer/5041216 to your computer and use it in GitHub Desktop.
Ban domains from Buddypress signup
// ====================================
// Limit signup by banning domains
function bp_as_restrict_signup_domains( $result ) {
$banned = array(
'spam1.com',
'spam2.com'
);
$error = 'Your email domain has been the source of spam. Please use another email address.';
$email = $result['user_email'];
$domain = array_pop(explode('@', $email));
if ( in_array($domain, $banned))
{
$result['errors']->add('user_email', __($error, 'bp-restrict-email-domains' ) );
};
return $result;
}
add_filter( 'bp_core_validate_user_signup', 'bp_as_restrict_signup_domains' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment