2

While creating an account , I want remove "email already exist validation" from CreatePost.php file

Path: \vendor\magento\module-customer\Controller\Account\createpost.php
2
  • why you want to remove this 'email already exist validation` validation
    – Amit Bera
    Sep 17, 2018 at 8:05
  • actually , i want to provide functionality like "customer can create account as supplier with same email id " and vice versa Sep 17, 2018 at 8:23

1 Answer 1

2

Please don't do that, Email address should be unique, if you do that you will end up with multiple users with the same email address, you thought a little if you ever want to load user by email ? something like this:

Magento\Customer\Api\CustomerRepositoryInterface

public function get($email, $websiteId = null);

Or with the object manager (not recommended but just for the exemple):

$CustomerModel = $objectManager->create('Magento\Customer\Model\Customer');
$CustomerModel->setWebsiteId(1);
$CustomerModel->loadByEmail($customerEmail);
$userId = $CustomerModel->getId();

I think you have the answer.

Update:

Path : vendor/magento/module-customer/Controller/Account/CreatePost.php::execute()

} catch (StateException $e) {
            $url = $this->urlModel->getUrl('customer/account/forgotpassword');
            // @codingStandardsIgnoreStart
            $message = __(
                'There is already an account with this email address. If you are sure that it is your email address, <a href="%1">click here</a> to get your password and access your account.',
                $url
            );
            // @codingStandardsIgnoreEnd
            $this->messageManager->addError($message);

Important: It's just to show you the piece of code, if you want to change the behavior of your Magento go ahead it's your responsibility and don't change it in this path, you have to rewrite it in app/code/...

4
  • but where should i put this Sep 17, 2018 at 8:25
  • No, you should put it anywhere, just to show that if you do that (remove email already exist validation), it will cause you problems later.
    – PЯINCƎ
    Sep 17, 2018 at 8:28
  • okay , can you show me? Where the code of validation ? Sep 17, 2018 at 9:41
  • Look my update.
    – PЯINCƎ
    Sep 17, 2018 at 10:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.