1
bfine107
only allow ____@myschool.edu to register
  • 2005/3/27 18:46

  • bfine107

  • Just popping in

  • Posts: 23

  • Since: 2005/2/11


How do I do that? I can add a module if you know of one that works.

But I figure this is a simple coding thing.

I'm running a site for my school and I only want _____@myschool.edu emails to be able to register.

Help!

2
wtravel
Re: only allow ____@myschool.edu to register

One possibility is to hack the register.php file. There are several places in which you can insert the hack. For example go to the line:
Quote:
case 'newuser':

You can insert a check there on the $email value.

Martijn

3
Mithrandir
Re: only allow ____@myschool.edu to register

Or find a regular expression that will disallow all email addresses that do NOT have @myschool.edu in them. Maybe someone will be able to give you the regex to use - I can't make heads or tails of regex.

When you've found the proper regex, you can put it in the relevant field in system admin -> preferences -> user settings

4
bfine107
Re: only allow ____@myschool.edu to register
  • 2005/3/29 14:29

  • bfine107

  • Just popping in

  • Posts: 23

  • Since: 2005/2/11


Thanks folks,
but what's a regex?
and what does a check on the email value look like?

thanks.

5
bfine107
Re: only allow ____@myschool.edu to register
  • 2005/4/13 13:52

  • bfine107

  • Just popping in

  • Posts: 23

  • Since: 2005/2/11


help?

6
wtravel
Re: only allow ____@myschool.edu to register

I am not that familiar with negative regex either, so I will just stick to the alternative . Open the file "include/functions.php" and lookup funtion "checkEmail". Change it to this and replace "myschools" and "edu" with the domain values of your choice (if you want to use another domain).

function checkEmail($email,$antispam = false)
{
if (!$email || !preg_match("/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+([\.][a-z0-9-]+)+$/i",$email)){
return false;
} else if (!preg_match("/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@myschools+([\.]edu+)+$/i",$email)) {
return false;
}
if ($antispam) {
$email = str_replace("@", " at ", $email);
$email = str_replace(".", " dot ", $email);
return $email;
} else {
return true;
}
}

If you want to stop using this check, simply remove the part from "else if" to "return false; }"

Martijn

7
wtravel
Re: only allow ____@myschool.edu to register

OK, tested this and it works.

Login

Who's Online

292 user(s) are online (114 user(s) are browsing Support Forums)


Members: 0


Guests: 292


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits