Skip to content

Instantly share code, notes, and snippets.

@wpchannel
Last active January 21, 2025 13:11
Show Gist options
  • Save wpchannel/dd0102a91c0930d181bb80a95b6e350d to your computer and use it in GitHub Desktop.
Save wpchannel/dd0102a91c0930d181bb80a95b6e350d to your computer and use it in GitHub Desktop.
Block emails for all Gravity Forms (Eric Jones spam)
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