forked from LiveCarta/LiveCartaWP
LAW-8882
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -397,3 +397,41 @@ function old_post_url_redirect(){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
add_action( "template_redirect", "old_post_url_redirect" );
|
add_action( "template_redirect", "old_post_url_redirect" );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add custom validation for CF7 form fields
|
||||||
|
*/
|
||||||
|
function is_business_email($email){
|
||||||
|
if(
|
||||||
|
preg_match('/@gmail.com/i', $email) ||
|
||||||
|
preg_match('/@hotmail.com/i', $email) ||
|
||||||
|
preg_match('/@outlook.com/i', $email) ||
|
||||||
|
preg_match('/@yahoo.com/i', $email) ||
|
||||||
|
preg_match('/@protonmail.com/i', $email) ||
|
||||||
|
preg_match('/@icloud.com/i', $email) ||
|
||||||
|
preg_match('/@me.com/i', $email) ||
|
||||||
|
preg_match('/@aol.com/i', $email) ||
|
||||||
|
preg_match('/@mail.com/i', $email) ||
|
||||||
|
preg_match('/@tutanota.com/i', $email) ||
|
||||||
|
preg_match('/@tuta.com/i', $email) ||
|
||||||
|
preg_match('/@live.com/i', $email) ||
|
||||||
|
preg_match('/@msn.com/i', $email) ||
|
||||||
|
preg_match('/@inbox.com/i', $email)
|
||||||
|
){
|
||||||
|
return false; // It's a publicly available email address
|
||||||
|
}else{
|
||||||
|
return true; // It's probably a company email address
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function custom_email_company_validation_filter( $result, $tag ) {
|
||||||
|
if ( 'company-email' == $tag->name ) {
|
||||||
|
$the_value = isset( $_POST['company-email'] ) ? trim( $_POST['company-email'] ) : '';
|
||||||
|
if (!is_business_email($the_value)) {
|
||||||
|
$result->invalidate($tag, "This form only accepts business emails. Please provide your work address.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
add_filter( 'wpcf7_validate_email*', 'custom_email_company_validation_filter', 20, 2 );
|
||||||
Reference in New Issue
Block a user