cancel
Showing results for 
Search instead for 
Did you mean: 

How to remove email validation from registration page magento2.3

How to remove email validation from registration page magento2.3

Can anyone help me to remove email validation form registration page in magento 2.3 or make it to non require field ?

 

I tried below things.

1) Remove "data-validate" for email in register.phtml file.

2) Make email as non require in "eav_attribute" table.

 

But still there is an error after i submit the registration form.

Error is "No such entity with email = , websiteId = 1".

 

Can anyone please help me ?

 

Thank you.

3 REPLIES 3

Re: How to remove email validation from registration page magento2.3

@niteshpatel 

 

You need to change below file as well

Magento\Customer\Model\ResourceModel\CustomerRepository.php

Magento\Customer\Model\Customer.php

 

Go to the 'eav_attribute' table in magento database, Find for the 'email' in 'attribute_code' column and find 'is_required' column and set the value to 0.

 

Additionally to the above answer you can change the input type from type="email" to type="text", then it will not be validated anymore as email.

Manish Mittal
https://www.manishmittal.com/

Re: How to remove email validation from registration page magento2.3

@Manish Mittal  I already modify the below files.

 

Magento\Customer\Model\ResourceModel\CustomerRepository.php

Magento\Customer\Model\Customer.php

 

I also tried to change 'email' in 'eav_attribute' table and set value to 0 in 'attribute_code' column.

I tried all solution which you have suggested.

But still error is coming. Smiley Sad

 

Is there any other solutions ?

Re: How to remove email validation from registration page magento2.3

@niteshpatel 

 

You are getting this cause of this line: 

$savedCustomer = $this->get($customer->getEmail(), $customer->getWebsiteId());
here its trying to get customer with email id and website id to save customer data and return same.
in this function:
public function save(CustomerInterface $customer, $passwordHash = null)
 
This is the function which is trying to get customer: 
public function get($email, $websiteId = null)
{
$customerModel = $this->customerRegistry->retrieveByEmail($email, $websiteId);
return $customerModel->getDataModel();
}
File: Model/ResourceModel/CustomerRepository.php
 If you will comment out these you will get another error  "We can't save the customer".
 
Its not that easy to remove email from mandatory field as this field is unique in Magento and most of things depends on that. I will not recommend to do this. Thanks
Manish Mittal
https://www.manishmittal.com/