Created
April 16, 2021 06:04
-
-
Save genesis16/226a2fe2df34f17f106d8617b464cf7c to your computer and use it in GitHub Desktop.
wp forms blacklist
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
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