The right way to do this is creating a customer attribute for the club cart number with a custom attribute model. There you just have to implement a validateValue() method and Magento will take care of validation, error messages and preventing registration.
Have a look at Mage_Customer_Model_Attribute_Data_Postcode to see how it works.
Example
class Your_Module_Model_Attribute_Data_Tescoclubcart_Number extends Mage_Eav_Model_Attribute_Data_Text
{
public function validateValue($value)
{
if ($this->checkCard($tescoClubCardNumber) === 'N') {
return array('Invalid Tesco Club Card Number');
}
return true;
}
}
To update the existing attribute, use this code in a setup script:
1- You have to create the attribute phone_number and then display it for the customer in register.phtml and edit.phtml, you have to follow this tuto
2- You have to Rewritte loginPostAction() from AccountController.php to your local codepool, you can follow this tuto and then you add this piece of code in loginPostAction():
if (strpos($login['username'], '@') === false){ //the user has entred a phone number
$telUser = $login['username'];
$customer = Mage::getModel('customer/customer')->getCollection()
->addAttributeToFilter('phone_number', $telUser)
->getFirstItem();
if($telUser == $customer->getPhoneNumber()){
$login['username'] = $customer->getEmail();
}
}
Best Answer
All validations are defined in
You can see validation-email
Override register.phtml to your theme
remove 'validate-email':true from data-validate