Last active
December 14, 2015 06:18
-
-
Save alexschreyer/5041216 to your computer and use it in GitHub Desktop.
Ban domains from Buddypress signup
This file contains 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
// ==================================== | |
// 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