Please Disable Your Browser Adblock Extension for our site and Refresh This Page!

our ads are user friendly, we do not serve popup ads. We serve responsible ads!

Refresh Page
Skip to main content
On . By CodimTh
Category:

Question:

How to prevent a specific email address domain from registering in drupal 8 ?

Solution:

The solution is:

  1. Install Restrict Domain Registration Module .
  2. visit 'admin/config/system/domain_register'
  3. Choose if you want to only allow, or disallow the domains from registering
  4. Enter the domain names you wish to allow/deny (one per line) in the format of 'foo.com'. Wildcards are allowed.
  5. Enter the error message you wish to show to the end user if the email address doesn't validate
  6. That's it!

If you want to Restrict Domain Registration just for Anonymous users you can use these patchs. or just override domain_registration.module file like this:

/**
 * Implements hook_form_form_id_form_alter().
 */
function domain_registration_form_user_register_form_alter(&$form, &$form_state, $form_id) {
  if(\Drupal::currentUser()->isAnonymous()){
    $form['#validate'][] = 'domain_registration_user_register_validate';
  }
}

Riadh Rahmi

Senior Web Developer (Drupal & Laravel)

I am a senior web developer, I have experience in planning and developing large scale dynamic web applications especially in Drupal and Laravel.