Skip to content

Instantly share code, notes, and snippets.

@mustardBees
Created June 29, 2015 15:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mustardBees/2653e2db5d8c3cb9c480 to your computer and use it in GitHub Desktop.
Save mustardBees/2653e2db5d8c3cb9c480 to your computer and use it in GitHub Desktop.
Formidable Pro form builder - function to block email from certain domains
<?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 );
@abahalkar
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment