محدود کردن ثبت نام به سرویس دهنده های مطرح و معتبر ایمیل در دروپال 7

پیدا کردن نرخ استفاده از سرویس دهندگان

SELECT substring_index(mail, '@', -1) domain, COUNT(*) email_count FROM users GROUP BY substring_index(mail, '@', -1) ORDER BY email_count DESC, domain L IMIT 100;

خروجی

| gmail.com                          |       87504 |
| yahoo.com                          |       50386 |
| mail.ru                            |        3275 |
| hotmail.com                        |        1674 |
| ymail.com                          |        1253 |
| outlook.com                        |        1210 |
| chmail.ir                          |         859 |
| gmil.com                           |         736 |
| gamil.com                          |         674 |
| mihanmail.ir                       |         476 |
| email.com                          |         446 |
| mailcatch.com                      |         396 |
| live.com                           |         309 |
| mailfa.com                         |         297 |
| emeil.ir                           |         287 |
| dust.harboxed.com                  |         266 |
| yandex.com                         |         259 |
| gmail.con                          |         249 |
| monkey.britainst.com               |         247 |
| tarafdari.ir                       |         247 |
| jmail.com                          |         243 |
| spamavert.com                      |         237 |
| rice.levening.com                  |         228 |
| ap.qqmuch.com                      |         224 |
| 163.com                            |         221 |
| all.britainst.com                  |         220 |
| mail.com                           |         217 |
| spambog.com                        |         214 |

سپس

function user_validate_mail($mail) {
  if (!$mail) {
    return t('You must enter an e-mail address.');
  }
  if (!valid_email_address($mail)) {
    return t('The e-mail address %mail is not valid.', array('%mail' => $mail));
  }
  $domain = substr(strrchr($mail, "@"), 1);
  $valid = array(
  'gmail.com',
  'yahoo.com',
  'live.com',
  'outlook.com',
  'hotmail.com',
  );
  if(!in_array($domain, $valid)) {
    return t('Please following mail providers: gmail.com - yahoo.com - live.com - outlook.com - hotmail.com');
  }
}

مسدود کردن ثبت نامی های قبلی

update users set status = 0 where substring_index(mail, '@', -1) = 'email.ir';

افزودن نظر جدید