1
greywolff
Registration restrictions ?
  • 2006/10/27 14:10

  • greywolff

  • Just popping in

  • Posts: 3

  • Since: 2006/10/27


ok ive searched but not finding an exact way to do what i want to do

I need to restrict new user registration to users with a specific email domain is there an easy way to do this ?

thanks

2
Mithrandir
Re: Registration restrictions ?

Hmmm - should be possible with the right regex pattern in "Enter emails that should not be used in user profile" in user info preferences.

You'd have to find the right regex, though, and disallow every email address that does NOT fulfil the regex.

I hope someone else will be able to help you with it.
"When you can flatten entire cities at a whim, a tendency towards quiet reflection and seeing-things-from-the-other-fellow's-point-of-view is seldom necessary."

Cusix Software

3
m0nty
Re: Registration restrictions ?
  • 2006/10/27 14:16

  • m0nty

  • XOOPS is my life!

  • Posts: 3337

  • Since: 2003/10/24


not easily.

1 method though that may work is to add as many email domains to the banned emails list in preferences.

add hotmail.com, gmail.com to the list and as many email domains as possible. except for the domain you want allowed.. it's a long way round and there are many to use..

the other way i think would mean editing maybe register.php and running some kind of check there.. off hand i can't say but it would be possible to do.. i'll take a look later and see if i can sort it for you when i have a bit more time..

4
m0nty
Re: Registration restrictions ?
  • 2006/10/27 14:19

  • m0nty

  • XOOPS is my life!

  • Posts: 3337

  • Since: 2003/10/24


actually just thinking about that..

@mith would it be easier just to reverse the banned emails logic, so that it fails if the regex doesn't match the 1 in the banned list? basically making the banned emails, allowed emails instead..

5
Mithrandir
Re: Registration restrictions ?

Actually, a well-placed ! in register.php and inputting the allowed domain in the user info preferences should do the trick.

However, if you have multiple allowed domains, this ought to work - try it out:

foreach ($xoopsConfigUser['bad_emails'] as $be) {
    if (!empty(
$be) && preg_match("/".$be."/i"$email)) {
        
$stop .= _US_INVALIDMAIL.'<br />';
        break;
    }
}


could be changed to

$found_domain false;
foreach (
$xoopsConfigUser['bad_emails'] as $be) {
    if (!empty(
$be) && preg_match("/".$be."/i"$email)) {
        
$found_domain true;
    }
}
if (!
$found_domain) {
        
$stop .= _US_INVALIDMAIL.'<br />';
}
"When you can flatten entire cities at a whim, a tendency towards quiet reflection and seeing-things-from-the-other-fellow's-point-of-view is seldom necessary."

Cusix Software

6
greywolff
Re: Registration restrictions ?
  • 2006/10/27 14:24

  • greywolff

  • Just popping in

  • Posts: 3

  • Since: 2006/10/27


so to be more specific i want to allow only emails that end with a .mil

7
m0nty
Re: Registration restrictions ?
  • 2006/10/27 14:27

  • m0nty

  • XOOPS is my life!

  • Posts: 3337

  • Since: 2003/10/24


try register.php

find >

foreach ($xoopsConfigUser['bad_emails'] as $be) {
        if (!empty(
$be) && preg_match("/".$be."/i"$email)) {
            
$stop .= _US_INVALIDMAIL.'<br />';
            break;


replace with

foreach ($xoopsConfigUser['bad_emails'] as $be) {
        if (!empty(
$be) && !preg_match("/".$be."/i"$email)) {
            
$stop .= _US_INVALIDMAIL.'<br />';
            break;


added a '!' before preg_match()

that should then deny any emails that aren't in the list..

8
Mithrandir
Re: Registration restrictions ?

the ! before preg_match() will work as long as there is only one regular expression - if there are multiple, it will always fail (unless the email address matches ALL expressions)

So give my suggestion a whirl and try putting in

.mil$

in the blocked domains list (that will now be changed to an allowed domains list)

if it doesn't work, try escaping the . with

\.mil$
"When you can flatten entire cities at a whim, a tendency towards quiet reflection and seeing-things-from-the-other-fellow's-point-of-view is seldom necessary."

Cusix Software

9
m0nty
Re: Registration restrictions ?
  • 2006/10/27 14:32

  • m0nty

  • XOOPS is my life!

  • Posts: 3337

  • Since: 2003/10/24


ahh, i hadn't tried it with multiple domains in the list.. ya learn somethin new everyday.. i'll remember that in case i have a need for it

10
greywolff
Re: Registration restrictions ?
  • 2006/10/27 14:56

  • greywolff

  • Just popping in

  • Posts: 3

  • Since: 2006/10/27


Mithrandir

your hack worked :) thanks

now i just need to add a nice little notice

:)

Login

Who's Online

161 user(s) are online (93 user(s) are browsing Support Forums)


Members: 0


Guests: 161


more...

Donat-O-Meter

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

Latest GitHub Commits