Jump to content

Blacklist @domain during registration


Recommended Posts

We want to block @aol emails from registering, even a message on the registration page will do.

 

Is there an addon/option for any of these? 

 

AOL has too many issues with email and we run our store behind a scaling AWS cluster for traffic.

Link to comment
Share on other sites

You can create an override to do this. For example, create override/controllers/AuthController.php with the following:

<?php
class AuthController extends AuthControllerCore
{
    protected function processSubmitCreate()
    {
        $email = trim(Tools::getValue('email_create'));
        if (Tools::strpos($email, '@aol.com') !== false) {
            $this->errors[] = Tools::displayError('AOL email addresses are not allowed');
            $_POST['email'] = trim(Tools::getValue('email_create'));
            unset($_POST['email_create']);
        } else {
            parent::processSubmitCreate();
        }
    }
   
    protected function processSubmitAccount()
    {
        $email = Tools::getValue('email');
        if (Tools::isSubmit('submitAccount')) {
            if (Tools::strpos($email, '@aol.com') !== false) {
                $this->errors[] = Tools::displayError('AOL email addresses are not allowed');
            }
        }
        parent::processSubmitAccount();
    }
} 

Remember to go to Advanced Parameters > Performance and then click the "Clear cache" button (or manually delete cache/class_index.php) so PrestaShop can find the override.

 

This override will display an "AOL email addresses are not allowed" error message when a customer tries to enter an email address with @aol.com and then click the "Create an account". If the customer enters a non-AOL email address and then tries to change it to an AOL email address on the next page and then clicks the "Register" button, they will also get the same error message.

 

If you want to make it clear that AOL email addresses are not allowed before customer enter an email address, you can edit themes/<your_theme>/authentication.tpl and add a message in there.

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...