Last active
January 21, 2025 13:11
-
-
Save wpchannel/dd0102a91c0930d181bb80a95b6e350d to your computer and use it in GitHub Desktop.
Block emails for all Gravity Forms (Eric Jones spam)
This file contains hidden or 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 wpc_block_emails_on_all_forms($result, $value, $form, $field) { | |
// Check if this is an e-mail field | |
if ($field->type === 'email') { | |
// List of e-mails to block | |
$blocked_emails = ['[email protected]', '[email protected]']; | |
// Standardize email format to avoid variations | |
if (in_array(strtolower(trim($value)), $blocked_emails)) { | |
$result['is_valid'] = false; | |
$result['message'] = __('This e-mail address is incorrect. Please use another one.', 'wpchannel'); | |
} | |
} | |
return $result; | |
} | |
add_filter('gform_field_validation', 'wpc_block_emails_on_all_forms', 10, 4); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment