I have been tasked with blocking specific email address domians from registering at our Drupal 6 site (gmail.com, aol.com & yahoo.com). I implemented some JQuery code to do this but the problem was that spammers with javascript disabled in their browser readily bypassed this prevention.
I also cannot use Drupal 6's Access Rules as we already have registered users on the site with those domains so this method blocks them from logging in so it's more of a going forward prevention that we would like to implement.
I found this code on Stack Overflow but the code was somewhat incomplete:
function example_data_form_user_register_alter(&$form,&$form_state) {
$form['mail']['#element_validate'] = 'example_mail_validate';
}
function example_mail_validate($element, &$form_state) {
if ( -- Whatever condition you like -- ) {
form_error($element, t('Free email is not allowed.'));
}
}
I thought it would be better to open a new question on this forum since it's Drupal specific.
I think what I need help with is filling in the gap where in the code it says: -- Whatever condition you like --
I am not a PHP guru so any help would be appreciated. I assume this is the spot where I would have some code that disallows the domains that I want to block.