Skip to content

Instantly share code, notes, and snippets.

@genesis16
Created April 16, 2021 06:04
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 genesis16/226a2fe2df34f17f106d8617b464cf7c to your computer and use it in GitHub Desktop.
Save genesis16/226a2fe2df34f17f106d8617b464cf7c to your computer and use it in GitHub Desktop.
wp forms blacklist
function wpf_blacklist_domains( $field_id, $field_submit, $form_data ) {
$domain = substr( strrchr( $field_submit, "@" ), 1 );
$blacklist = array( 'yahoo.com', 'hotmail.com' );
if( in_array( $domain, $blacklist ) ) {
wpforms()->process->errors[ $form_data['id'] ][ $field_id ] = esc_html__( 'We apologize for any inconvenience, we are unable to accept emails from this domain.', 'wpforms' );
return;
}
}
add_action('wpforms_process_validate_email', 'wpf_blacklist_domains', 10, 3 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment