Created
June 29, 2015 15:38
-
-
Save mustardBees/2653e2db5d8c3cb9c480 to your computer and use it in GitHub Desktop.
Formidable Pro form builder - function to block email from certain domains
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Block persistent marketers | |
* | |
* @param $errors | |
* @param $posted_field | |
* @param $posted_value | |
* | |
* @return mixed | |
*/ | |
function iweb_block_persistent_marketers( $errors, $posted_field, $posted_value ) { | |
if ( 85 == $posted_field->id ) { | |
$blocked = array( 'example.com' ); | |
if ( filter_var( $posted_value, FILTER_VALIDATE_EMAIL ) ) { | |
$domain = array_pop( explode( '@', $posted_value ) ); | |
if ( in_array( $domain, $blocked ) ) { | |
$errors['field' . $posted_field->id] = 'Blocked email domain.'; | |
} | |
} | |
} | |
return $errors; | |
} | |
add_filter( 'frm_validate_field_entry', 'iweb_block_persistent_marketers', 10, 3 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You may use this plugin https://wordpress.org/plugins/block-email-formidable-form/