-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added WooCommerce's registration hook for email validation #1
base: master
Are you sure you want to change the base?
Conversation
@@ -52,7 +52,7 @@ function validateEMailAddress( $strEMailAddress ) | |||
|
|||
function checkSyntax( &$strEMailAddress ) | |||
{ | |||
return preg_match( "/^[0-9a-z_]([-_\.]*[0-9a-z])*@[0-9a-z]([-\._]*[0-9a-z])*\\.[a-z]{2,3}$/i", $strEMailAddress ) == 1 ; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Email addresses with a '+' in them represent valid email addresses (even though they can be somewhat abused). I use them all the time, when I sign up for newsletters etc. to make sure, I know exactly who passed on my email address if I should receive spam. Also there are new top-level domains, that have up to 24! (insane) characters.
wget -qO - http://data.iana.org/TLD/tlds-alpha-by-domain.txt | tail -n+2 | less
shows all allowed top level domains.
@@ -67,8 +67,6 @@ function checkHostName( &$strHostName ) | |||
{ | |||
if ( preg_match( "/^[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}$/", $strHostName ) ) | |||
$numHostIP = @gethostbyaddr ( $strHostName ) ; | |||
else if ( $this -> countChars( $strHostName, "." ) == 1 ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This assumes, that all domains always have a 'www' subdomain configured. In my case that wasn't / isn't the case (even though it might not be smart). But the absence of a 'www' CNAME or A record should not be abused as an indicator for spammyness I believe.
wp-mail-validator.php
Outdated
@@ -108,6 +108,7 @@ function getmxrr($hostName, &$mxHosts, &$mxPreference) | |||
function wp_mail_validator_init() { | |||
add_filter('pre_comment_approved', 'wp_mail_validator_validate_comment_mail', 99, 2); | |||
add_filter('registration_errors', 'wp_mail_validator_validate_registration_mail', 99, 3); | |||
add_filter('woocommerce_registration_errors', 'wp_mail_validator_validate_registration_mail', 10, 3); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And this is already covered in my previous PR for adding verification to the WooCommerce registration forms.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And thank you for this Plugin - made my life quite a bit better :D
…email addresses dependent on whether woocommerce is activated or not
Love you plugin and its simplicity and want to contribute to making it even better.