| 1 |
<?php |
| 2 |
|
| 3 |
function wppb_toolbox_check_email_domain( $message, $field, $request_data, $form_location ) { |
| 4 |
|
| 5 |
$type = wppb_toolbox_get_settings( 'forms', 'restricted-email-domains-type' ); |
| 6 |
|
| 7 |
if ( $type == false ) return $message; |
| 8 |
|
| 9 |
$restricted_domains = wppb_toolbox_get_settings( 'forms', 'restricted-email-domains-data' ); |
| 10 |
|
| 11 |
if ( $restricted_domains == false ) return $message; |
| 12 |
|
| 13 |
$domain = strtolower( substr( strrchr( $request_data['email'], '@' ), 1 ) ); |
| 14 |
$validation_message = wppb_toolbox_get_settings( 'forms', 'restricted-email-domains-message' ); |
| 15 |
|
| 16 |
if ( $type == 'allow' ) { |
| 17 |
|
| 18 |
if ( !in_array( $domain, $restricted_domains ) ) |
| 19 |
return $validation_message; |
| 20 |
|
| 21 |
} else if ( $type == 'deny' ) { |
| 22 |
|
| 23 |
if ( in_array( $domain, $restricted_domains ) ) |
| 24 |
return $validation_message; |
| 25 |
|
| 26 |
} |
| 27 |
|
| 28 |
return $message; |
| 29 |
} |
| 30 |
add_filter( 'wppb_check_form_field_default-e-mail', 'wppb_toolbox_check_email_domain', 20, 4 ); |
| 31 |
|