Topic: only emails with a defined suffix

Hi, I don't know if I post this topic in the right forum! I want that only people who uses an email with a suffix that I myself define, can register in the forum. For example the emails which ends in @gmail.com. Is there ant tick for doing this? Thanks in advance for your help

Re: only emails with a defined suffix

You can modify the valid email checker in include/email.php

return preg_match('/^(([^<>()[\]\\.,;:\s@"\']+(\.[^<>()[\]\\.,;:\s@"\']+)*)|("[^"\']+"))@((\[\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\])|(([a-zA-Z\d\-]+\.)+[a-zA-Z]{2,}))$/', $email);

to

return preg_match('/^(([^<>()[\]\\.,;:\s@"\']+(\.[^<>()[\]\\.,;:\s@"\']+)*)|("[^"\']+"))@gmail\.com$/', $email);

Re: only emails with a defined suffix

Thank you for the reply. the only thing left is that I am making a froum for a university staff and their email addresses are like this:
@hf.uio.com, @ili.uio.com, @mat.uio.com and so on... Your reply solves my first questions. but regarding this type of emails, how should I change the code? Thanks again.

4

Re: only emails with a defined suffix

erinther wrote:

Thank you for the reply. the only thing left is that I am making a froum for a university staff and their email addresses are like this:
@hf.uio.com, @ili.uio.com, @mat.uio.com and so on... Your reply solves my first questions. but regarding this type of emails, how should I change the code? Thanks again.

Either you define all the allowed subdomains:

return preg_match('/^(([^<>()[\]\\.,;:\s@"\']+(\.[^<>()[\]\\.,;:\s@"\']+)*)|("[^"\']+"))@(hf|ili|mat)\.uio\.com$/', $email);

Or you just allow everyone from uio.com to register:

return preg_match('/^(([^<>()[\]\\.,;:\s@"\']+(\.[^<>()[\]\\.,;:\s@"\']+)*)|("[^"\']+"))@(.+\.|)uio\.com$/', $email);

(You should test that code before you use it, I just copied Nibbler's example and changed the domain.)

Re: only emails with a defined suffix

Hi there,
I've a similar problem with  WPMU. It uses this expression to validate emails:

ereg('^[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+'.'@'.
        '[-!#$%&\'*+\\/0-9=?A-Z^_`a-z{|}~]+\.'.
        '[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+$', $email)

and now I want it to validate emails with

*.uio.no

suffix. I asked people in wpmu's forum, but didnæt get any useful response. Thanks for your help.

Re: only emails with a defined suffix

This isn't a support forum for WPMU wink

Re: only emails with a defined suffix

I know that, and I really apologize, but I had no choice. I can delete it if you want.