can someone please help me out, I am using Buddypress/wordpress and i want to ban some domain extensions e.g .pl, .ru, .asia. i have tried the following functions which works for email domain but not extensions.
function my_bp_ban_domains( $result ) {
$banned = array('.ru', '.pl');
$error = 'God catch you brah !!!, Spammers are not welcome here, try your luck elsewhere.';
$email = $result['user_email'];
$domain = array_pop(explode('@', $email));
if ( in_array($domain, $banned)) {
$result['errors']->add('user_email', __($error, 'my_bp_ban_domains' ) );
};
return $result;
}
add_filter( 'bp_core_validate_user_signup', 'my_bp_ban_domains' );
Below should work fine. I just go further and split domain using
.and take last item in array:Notice
$banned = array('ru', 'pl');is changed a little (leading dots removed)