how to block registration from personal emails: gmail, hotmail, etc. ?

Discussion and education for beginner / novice programmers interested in embarking on the development process to take advantage of the extensible nature of the Joomla! CMS.

Moderators: tjay, seadap, Rogue4ngel, matthewhayashida

Forum rules
Post Reply
dumbidiot
Joomla! Fledgling
Joomla! Fledgling
Posts: 3
Joined: Mon Nov 19, 2007 1:02 am

how to block registration from personal emails: gmail, hotmail, etc. ?

Post by dumbidiot » Mon Nov 19, 2007 6:25 am

I need to filter out the regestrations to my site and only allow users to enter their business emails and block anyone trying to use a personal account like hotmail. I've looked through the extensions for joomla and none seem to have any ways of filtering registration email. Is there a way to add this to the standard login module in PHP?  ???

kdevine
Joomla! Apprentice
Joomla! Apprentice
Posts: 18
Joined: Thu Mar 02, 2006 8:38 pm
Location: Baltimore, MD

Re: how to block registration from personal emails: gmail, hotmail, etc. ?

Post by kdevine » Mon Nov 19, 2007 1:51 pm

This should be fairly easy for J! 1.5

You would need a User plugin with a onBeforeStoreUser method to validate the email address. Check out the example plugin in plugins/user and this tutorial will help as well...

http://forum.joomla.org/index.php?topic=233628

If this is for 1.0.x I'm afraid I don't have any ideas.

dumbidiot
Joomla! Fledgling
Joomla! Fledgling
Posts: 3
Joined: Mon Nov 19, 2007 1:02 am

Re: how to block registration from personal emails: gmail, hotmail, etc. ?

Post by dumbidiot » Mon Nov 19, 2007 2:30 pm

I think i found the part of the code that validates the form:

Code: Select all

         if (form.name.value == "") {
            alert( "<?php echo addslashes( html_entity_decode(_REGWARN_NAME) );?>" );
         } else if (form.username.value == "") {
            alert( "<?php echo addslashes( html_entity_decode(_REGWARN_UNAME) );?>" );
         } else if (r.exec(form.username.value) || form.username.value.length < 3) {
            alert( "<?php printf( addslashes( html_entity_decode(_VALID_AZ09_USER) ), addslashes( html_entity_decode(_PROMPT_UNAME) ), 2 );?>" );
         } else if (form.email.value != "gmail") {
            alert( "<?php echo addslashes( html_entity_decode(_REGWARN_MAIL) );?>" );
         } else if (form.password.value.length < 6) {
            alert( "<?php echo addslashes( html_entity_decode(_REGWARN_PASS) );?>" );
         } else if (form.password2.value == "") {
            alert( "<?php echo addslashes( html_entity_decode(_REGWARN_VPASS1) );?>" );
         } else if ((form.password.value != "") && (form.password.value != form.password2.value)){
            alert( "<?php echo addslashes( html_entity_decode(_REGWARN_VPASS2) );?>" );
         } else if (r.exec(form.password.value)) {
            alert( "<?php printf( addslashes( html_entity_decode(_VALID_AZ09) ), addslashes( html_entity_decode(_REGISTER_PASS) ), 6 );?>" );
         } else {
            form.submit();


but i have no idea how to add the form content checking

kdevine
Joomla! Apprentice
Joomla! Apprentice
Posts: 18
Joined: Thu Mar 02, 2006 8:38 pm
Location: Baltimore, MD

Re: how to block registration from personal emails: gmail, hotmail, etc. ?

Post by kdevine » Mon Nov 19, 2007 2:39 pm

I don't think this would work...
if (form.email.value != "gmail")

Even if they provided a gmail address it would still return false. You need a regex check for gmail.

dumbidiot
Joomla! Fledgling
Joomla! Fledgling
Posts: 3
Joined: Mon Nov 19, 2007 1:02 am

Re: how to block registration from personal emails: gmail, hotmail, etc. ?

Post by dumbidiot » Mon Nov 19, 2007 11:54 pm

i have no clue how to set up a regex

Code: Select all

   }   else if (eregi('^[a-zA-Z0-9._-]+@[gmail]+\.[a-zA-Z.]{2,5}$', $email)){
            alert( "<?php echo addslashes( html_entity_decode(_REGWARN_MAIL) );?>" );


this does not seem to work


Post Reply