WPForms Email Blacklist

I’ve been receiving handwritten spam emails from certain companies trying to sell their services to me. Instead of letting them pollute my inbox and CRM, I wrote this quick snippet to create an email blacklist in WPForms. The user thinks it was successfully submitted, but the email is not sent or added to the Entries screen. If you have logging enabled, it will show up in the WPForms Log (screenshot)

Add this to your core functionality plugin, or theme’s functions.php file.

<?php
/**
* WPForms Email Blacklist
*
* @author Bill Erickson
* @link http://www.billerickson.net/code/wpforms-email-blacklist
*
* @param string $honeypot, empty if not spam, honeypot text is used in WPForms Log
* @param array $fields
* @param array $entry
* @param array $form_data
*/
function be_wpforms_email_blacklist( $honeypot, $fields, $entry, $form_data ) {
// Use the email as the key. The value will be used in the log
$blacklist = array(
'[email protected]' => 'Ranks India',
);
foreach( $form_data['fields'] as $id => $field ) {
if( 'email' == $field['type'] && array_key_exists( $entry['fields'][$id], $blacklist ) )
$honeypot = '[Blacklist] ' . $blacklist[$entry['fields'][$id]];
}
return $honeypot;
}
add_filter( 'wpforms_process_honeypot', 'be_wpforms_email_blacklist', 10, 4 );

Bill Erickson

Bill Erickson is a freelance WordPress developer and a contributing developer to the Genesis framework. For the past 14 years he has worked with attorneys, publishers, corporations, and non-profits, building custom websites tailored to their needs and goals.

Ready to upgrade your website?

I build custom WordPress websites that look great and are easy to manage.

Let's Talk