[FIX] Validate email address input for customer registration
Posted: Thu Aug 19, 2010 12:25 am
This fix includes some optional extras in the second and third posts but the first modification is required to get any new customer registrations checked for valid email addresses (including spaces).
Until now, the only time the function is_email_address() in general.php was used, was to validate guest checkout orders and not customer registrations. Stupid, stupid mistake but this fix resolves that and passes everything through.
IMPORTANT: The quoted code below only works with 5.5.x and above... For 5.0.6 see last post.
Open: includes/classes/class.customer.php
Find:
After, Add
Find:
After, Add
Until now, the only time the function is_email_address() in general.php was used, was to validate guest checkout orders and not customer registrations. Stupid, stupid mistake but this fix resolves that and passes everything through.
IMPORTANT: The quoted code below only works with 5.5.x and above... For 5.0.6 see last post.
Open: includes/classes/class.customer.php
Find:
Code: Select all
// Does an account with this email address already exist?
if ($this->AccountWithEmailAlreadyExists($customerData['custconemail'])) {
$this->CreateAccountStep1("already_exists");
}
Code: Select all
// MOD Force validation of the email using existing function
else if(!is_email_address($customerData['custconemail'])) {
$this->CreateAccountStep1("invalid_email");
}
// MOD END
Code: Select all
if ($Error == "already_exists") {
// The email address is taken, they have to choose another one
$GLOBALS['ErrorMessage'] = sprintf(GetLang('AccountEmailTaken'), isc_html_escape($emailAddress));
}
Code: Select all
//MOD validate email address
else if ($Error == "invalid_email") {
$GLOBALS['ErrorMessage'] = GetLang('AccountEnterValidEmail');
}