Allow specific domain in Joomla user registration

 

This article will show you  how to allow user registration from particular domain – such as ieee.org , in Joomla. If you want to restrict/ban particular domain, you can install Restricted Registration extension. You need to have FTP/CPanel access to make changes in Joomla core files and it is always a good practice to back up database .

The Email validation in Joomla is handled by a JavaScript file  validate.js – full path is root/media/system/js/validate.js 

  • Download this validate.js file .
  • Open it with web development/Text editing software. Avoid using notepad because it doesn’t parse the code well while saving. I am using Dreamweaver.
  • Go to Line number 53

regex=/^[a-zA-Z0-9._-]+@([a-zA-Z0-9.-]+\.)+[a-zA-Z0-9.-]{2,4}$/;

validate email code joomla

This is a Regular Expression. If you are a computer science Engg., you might know it or else read it here :  http://en.wikipedia.org/wiki/Regular_expression

  •  Change the second and third part of the regular expression according to your needs. (i.e) domain and TLD.

change email

  • Now save the file and upload it to media/system/js/
Any user who gives email address other than @ieee.org will not be allowed to register. It will show warning.
email registration
Update (17th Jan, 2013):

I got few emails enquiring for .EDU TLD (Educational content).  The syntax is

regex=/^[a-zA-Z0-9._-]+@([a-zA-Z0-9.-]+\.)+edu$/;

(or)

regex=/^[a-zA-Z0-9._-]+@([a-zA-Z0-9.-]+\.)+[edu]{3}$/;

I also found that the original syntax I prescribed in the image works but is semantically incorrect. The number 2,4 inside flower braces (i.e) [org]{2,4} means the minimum number of characters in TLD is 2 and maximum characters is 4.

change email

 

Since we had specifically mentioned ORG, there is no need to add character size limit in the regular expression. Not necessary !!!

 

Also read...

Leave a Reply