Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By droople on
I am working on a students' site and I only want people with emails ending to in ".ac.uk" to be able to register.
How do I go about this, so that any other email type will give error during registration
Thanks
Comments
Guess you'll have to do some coding.
You'd have to make a new module, unless you wanna hack the user-module.
Maybe there is allread a module out there that does this.
How to do it with a small module
How to do it with a small module which is much prefered to hacking the user module. Create a directory under the modules directory called limitemail and place the following in a file call limitemail.module.
Enable the module and you should be be good to go.
This didn't work here is the
This didn't work here is the file path I set up /public_html/drupal/modules/limitemail/limitemail.module
I acivated the module as well
Please help
Thanks
When you say it does not work
When you say it does not work what does that mean?
I still managed to register
I still managed to register with a .com email address after going through that process
Try this
At the beginning of the validation function add a call to drupal_set_message(), something like this
to see if it is even entered. If not, you can do the same sort of thing in the form_alter hook to determine what code is or is not running.
thanks but wow, I am a
thanks but wow, I am a novice couldn't understand a thing there.
Could you put that in simple English if possible
Thanks mate
Ok Change the module like this
Here is a modified version of the module to let you determine what is going on
All those calls to drupal_set_message will add output to the message error when you view/submit the user registration/edit form. At the very least you should see the output "limitemail_form_alter: entered, form id = ?" (where ? is a value). The question is which ones do you see, the ones for limitemail_form_alter should show when the form is display, the ones for limitemail_validation when the firm is submitted.