Stop registration from domains WordPress BuddyPress function. If you have a WordPress site that uses BuddyPress registation page and you have a lot of spam registration from certain domains this funtion which you add to your theme function file should help. There are functions that only work with WordPress registration, this one only works with BuddyPress registration. You could use a plugin, but I rather use a function than a plugin.
I found this code here: https://alexschreyer.net/web-programming/limit-buddypress-registration-by-domain/
// Limit signup by banning domains function bp_as_restrict_signup_domains( $result ) { $banned = array( 'spam1.ru', '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' );