1

Topic: Restrict signup emails

How would I go about restricting email addresses used during signup?

Example: I only want users with @gmail.com or @hotmail.com.


Also, could this work for emails with prefixes?

Example: user@example.website.com?

2

Re: Restrict signup emails

Can be done in the CP - "ban options".

3

Re: Restrict signup emails

Yes, this can restrict certain email addresses but I want my site to be exclusive to only a handful of email addresses.

Example: ONLY users with xxx@gmail.com or xxx@hotmail.com can sign up.

4

Re: Restrict signup emails

Ok so I found the code for the banned email list in lib.account_register.php. How do I reverse this code to ONLY allow the emails in the list to register?

Here's the code:

    //------------------------------------------------
    // Check if email address is allowed
    //------------------------------------------------
    $emails = explode("\n", $PREFS->conf['banned_emails']);


    //------------------------------------------------
    // Check if the email is banned
    //------------------------------------------------
    foreach ($emails as $value)
    {
        $value = trim($value);
        if (substr($value, 0, 1) == '@'  &&  strpos($email, $value) !== false)
        {
             $TEMPLATE->set_message("error", ($LANG['register']['banned_email']), 0, 0);
             return 0;
        }
        elseif ($value == $email)
        {
            $TEMPLATE->set_message("error", ($LANG['register']['banned_email']), 0, 0);
            return 0;
        }
    }


    if (!$type_id)
    {
        $TEMPLATE->set_message("error", ($LANG['register']['empty_type_id']), 0, 0);
        return 0;
    }


    $query_keys = $query_values = "";
    $items_values = array();

5

Re: Restrict signup emails

Got it!

Changed:

$value = trim($value);
        if (substr($value, 0, 1) == '@'  &&  strpos($email, $value) !== false)

To:

$value = trim($value);
        if (substr($value, 0, 1) == '@'  &&  strpos($email, $value) == false)

(Just removed the "!")