How to stop spamming on contact form 7

How to stop spamming on contact form 7

If you’re experiencing issues with spam on your Contact Form 7, here are some measures you can take to mitigate and prevent spam submissions:

  1. Enable CAPTCHA: Utilize a CAPTCHA (Completely Automated Public Turing test to tell Computers and Humans Apart) plugin to add an additional layer of security to your contact form. This will require users to complete a challenge to prove they are human and not a bot.
  2. Use a Spam Filter Plugin: Install and activate a spam filter plugin, such as Akismet or reCAPTCHA, specifically designed to identify and block spam submissions. These plugins use advanced algorithms to analyze and filter out spam messages.
  3. Implement Honeypot Technique: The honeypot technique involves adding a hidden field to your contact form that only bots can see. Legitimate users won’t fill out this hidden field, but spam bots may, triggering the form to reject the submission.
  4. Set Form Restrictions: Configure your Contact Form 7 to include restrictions or validation rules, such as requiring specific fields to be completed, setting character limits, or using regular expressions to validate input. This can help prevent automated spam bots from successfully submitting the form.
  5. Limit Form Accessibility: Consider implementing measures to restrict access to your form, such as requiring user registration or adding a time delay before the form can be accessed. This can help deter spam bots that target unprotected forms.
  6. Monitor and Review Submissions: Regularly review the submissions you receive through your Contact Form 7 and identify any patterns or recurring spam messages. This will help you identify potential weaknesses in your spam prevention measures and allow you to fine-tune your strategies accordingly.
  7. Update Contact Form 7 Plugin: Ensure that you have the latest version of the Contact Form 7 plugin installed. Plugin updates often include security patches and bug fixes that can help prevent spam.
  8. Consider Third-Party Anti-Spam Solutions: If the above measures are not sufficient, you may want to explore third-party anti-spam solutions specifically designed for WordPress websites. These solutions offer advanced spam protection features and can be integrated with Contact Form 7.

By implementing these measures, you can significantly reduce the amount of spam submissions you receive through your Contact Form 7. Remember to regularly monitor and adjust your spam prevention strategies to stay ahead of evolving spam techniques.

I have implemented the above on my contact form 7 forms and am still receiving considerable amounts of spam. Even with reCaptcha and a challenge question. It seems they are either submitting the forms manually or possibly using AI to spam my forms. The following added to your WordPress functions file will block all urls from being submitted on forms. Hopefully this slows them down. Feel free to use this code yourself. I have tested it and it works!

					add_filter( 'wpcf7_validate_text', 'no_urls_allowed', 10, 3 );
add_filter( 'wpcf7_validate_text*', 'no_urls_allowed', 10, 3 );
add_filter( 'wpcf7_validate_textarea', 'no_urls_allowed', 10, 3 );
add_filter( 'wpcf7_validate_textarea*', 'no_urls_allowed', 10, 3 );
function no_urls_allowed( $result, $tag ) {

	$tag = new WPCF7_Shortcode( $tag );

	$type = $tag->type;
	$name = $tag->name;

	$value = isset( $_POST[$name] )
		? trim( wp_unslash( strtr( (string) $_POST[$name], "\n", " " ) ) )
		: '';

	// If this is meant to be a URL field, do nothing
	if ( 'url' == $tag->basetype || stristr($name, 'url') ) {
		return $result;

	// Check for URLs
	$value = $_POST[$name];
	$not_allowed = array( 'http://', 'https://', 'www.', '[url', '<a ', ' seo ', '.com', '.net', '.org', '.xyz', '.ga', '.ly' );
	foreach ( $not_allowed as $na ) {
		if ( stristr( $value, $na ) ) {
			$result->invalidate( $tag, 'URLs are not allowed' );
			return $result;
	return $result;


Share this

Leave a Comment

Your email address will not be published. Required fields are marked *

Related posts

Scroll to Top