Skip to content
How to Block Spam With Gravity Forms Using IP and Logic

How to Block Spam Bots Using Gravity Forms IP and Logic

Spam is one of the most frustrating problems with WordPress contact forms, especially when the same person or bot keeps submitting the same message over and over again.

Standard spam protection can stop a lot of automated submissions, but sometimes a persistent spam campaign still gets through. You block one submission, another appears. You block the IP address, and the next message arrives from a completely different IP.

At that point, you need another layer of protection.

In this guide, we’ll look at two ways to stop persistent Gravity Forms spam in WordPress: blocking known IP addresses and using Gravity Forms conditional logic to prevent suspicious submissions from being sent in the first place.

The second method is especially useful when a spammer is rotating IP addresses but continues using recognizable names, URLs, phrases, or other patterns in their messages.

Why Gravity Forms Spam Keeps Coming Back

In the real-world example behind this tutorial, a client was repeatedly receiving credit card scam messages through a Gravity Forms contact form.

The submissions were clearly spam, and initially the obvious solution was to block the IP address associated with the sender.

That works well when the spam continues coming from the same IP.

The problem is that many bots and persistent spammers don’t stay on one IP address. They may use proxies, VPNs, bot networks, or other systems that allow their IP address to change between submissions.

You can block one IP today and receive essentially the same spam from another IP tomorrow.

Instead of continuing to chase IP addresses, we can also make the form recognize the content of the spam itself.

Method 1: Block Gravity Forms Spam Using the IP Address

If the spam is repeatedly coming from the same source, blocking its IP address is a logical first step.

Find the Spam Submission’s IP Address in Gravity Forms

Gravity Forms stores useful information about form submissions inside its Entries section.

From your WordPress dashboard, navigate to:

Forms → Entries

Select the form receiving the spam and open one of the unwanted submissions.

Review the entry details and locate the IP address associated with the submission.

If multiple spam submissions are coming from the same IP address, blocking that IP can be an effective solution.

Block the Spam IP Address Using Wordfence

If you’re using Wordfence for WordPress security, you can block the offending IP address directly through Wordfence.

Open Wordfence in the WordPress dashboard and navigate to its blocking tools.

Add the IP address associated with the spam submission to your block list.

Once blocked, traffic from that IP address will no longer be able to interact with the website normally.

This is useful when you’re dealing with a repeat offender using a consistent IP address.

What If the Spammer Keeps Changing IP Addresses?

If you review several Gravity Forms spam entries and notice that every submission comes from a different IP address, manually blocking each IP quickly becomes ineffective.

You might block:

123.45.67.89

only for the next submission to come from:

98.76.54.32

and the next one from somewhere else entirely.

Instead of focusing on where the submission is coming from, start looking at what the submission contains.

This is where Gravity Forms conditional logic becomes surprisingly useful as an additional spam prevention tool.

Method 2: Block Gravity Forms Spam With Conditional Logic

Gravity Forms conditional logic is normally used to customize how a form behaves based on a visitor’s answers. But we can use that same functionality to stop certain spam submissions before they’re ever sent.

Identify Patterns in the Spam Messages

Start by looking through several spam entries and comparing them.

Even when IP addresses change, automated spam campaigns frequently reuse certain information.

That might include:

  • A specific name.
  • A repeated phrase.
  • A website address.
  • A domain name.
  • The word www.
  • http or https.
  • A particular product or service.
  • Repeated wording used by the same scam campaign.

If you can identify something that appears consistently in the unwanted submissions, you can potentially use that pattern to stop the form from being submitted.

Add Conditional Logic to the Gravity Forms Submit Button

Instead of allowing the spam submission to go through and trying to filter it afterward, we can prevent the bot from submitting the form at all.

Edit the affected form in Gravity Forms and open the settings for the Submit button.

Enable conditional logic.

Gravity Forms allows you to control when the Submit button appears based on information entered into other fields.

Normally, this might be used to show a Submit button only after someone selects a particular option or completes a required part of the form.

For spam prevention, we’re going to reverse that idea and hide the button when suspicious content appears.

Example: Hide the Submit Button When a Spam Phrase Appears

Imagine that the same spammer repeatedly includes a particular phrase in the Message field.

You can create conditional logic that effectively says:

Only show the Submit button if the Message field does not contain that phrase.

For a normal visitor, nothing changes. They fill out the form and the Submit button remains available.

But when the bot inserts the phrase associated with the spam campaign, the condition is triggered and the Submit button disappears.

The bot can fill out the entire form, but it no longer has a button available to submit it.

Block Gravity Forms Messages Containing URLs

Another useful application is blocking URLs.

A large percentage of contact form spam exists because the spammer wants to send you a link.

Depending on the purpose of your contact form, legitimate visitors may have little or no reason to include a website address in the Message field.

You can create conditional rules looking for common URL patterns such as:

  • http
  • https
  • www
  • Specific domains repeatedly appearing in spam.

If one of those patterns appears, the Submit button can be hidden.

This can eliminate an entire category of automated spam without requiring you to identify every IP address associated with the bot.

Add a Message for Legitimate Visitors

There is one important consideration when hiding the Submit button.

A real person might legitimately type something that triggers your spam rule. For example, someone may genuinely need to send you a URL.

Instead of leaving that visitor wondering why the Submit button disappeared, you can use additional Gravity Forms conditional logic to display a message explaining the restriction.

For example:

Links cannot be submitted through this form. Please remove the URL and try again.

A legitimate visitor can understand the instruction and modify their message.

A basic automated spam bot generally won’t.

Why Conditional Logic Can Stop Automated Form Spam

Many bots are designed around a predictable workflow:

  1. Find a form.
  2. Identify the available fields.
  3. Insert predetermined content.
  4. Locate the Submit button.
  5. Submit the form.

Conditional logic interferes with that workflow.

The bot enters the content that triggers your rule, and the interface changes. The Submit button it expected to use is no longer available.

Instead of trying to determine whether every visitor is human, you’re creating a condition that the specific spam campaign can’t satisfy.

IP Blocking vs. Gravity Forms Conditional Logic

These methods solve slightly different problems.

When IP Blocking Makes Sense

IP blocking is useful when:

  • The same IP repeatedly submits spam.
  • You have identified a clearly malicious source.
  • The spammer isn’t rotating IP addresses.

When Conditional Logic Makes Sense

Gravity Forms conditional logic can be useful when:

  • The spammer constantly changes IP addresses.
  • The spam submissions contain recognizable phrases.
  • The same name or domain appears repeatedly.
  • The submissions consistently contain URLs.
  • Traditional IP blocking has become a game of whack-a-mole.

In practice, you don’t necessarily need to choose one or the other.

You can use both.

Use Multiple Layers of WordPress Spam Protection

This technique isn’t meant to replace dedicated WordPress security or anti-spam tools.

Instead, think of it as another layer.

A WordPress website might use a combination of:

  • Gravity Forms built-in features.
  • CAPTCHA or other bot protection.
  • Wordfence or another security firewall.
  • IP blocking.
  • Conditional logic.
  • Form validation.
  • Server-level security.

No single method catches every type of spam. Layering multiple techniques makes it more difficult for automated submissions to reach your inbox.

Don’t Block More Than You Need To

One important rule when creating custom spam conditions is to start narrow.

If one particular phrase is causing the problem, block that phrase first.

If one domain keeps appearing, target that domain.

If nearly every spam message contains http while legitimate messages almost never do, then consider blocking URLs.

Be especially careful with common words. Blocking every message containing a broad term could prevent legitimate visitors from contacting you.

A narrow rule reduces the chance of accidentally blocking real leads, and you can always expand your conditions later if the spam campaign changes.

How to Test Your Gravity Forms Spam Protection

After adding conditional logic, always test the form yourself.

Test a Legitimate Submission

First, submit a normal message that should be accepted.

Confirm that:

  • The Submit button appears normally.
  • The form submits successfully.
  • The notification email arrives.
  • The entry is recorded correctly in Gravity Forms.

Test a Blocked Submission

Next, test the condition you’re using to identify spam.

Enter the blocked phrase, URL, name, or other trigger into the appropriate field.

Confirm that the Submit button disappears and, if you’ve added one, your explanatory message appears.

Testing both scenarios is important. Stopping spam doesn’t help if you accidentally stop legitimate leads at the same time.

A Simple Way to Make Gravity Forms Fight Back

Persistent WordPress spam can become frustrating because spammers adapt.

You block an IP address. They use another one.

You delete the message. Another identical submission appears.

Instead of continually reacting to each new entry, look for something the spam campaign keeps repeating.

Then use the form’s own logic against it.

If the spammer always includes a particular name, phrase, URL, or domain, Gravity Forms conditional logic can recognize that information and remove the Submit button before the message ever reaches you.

Final Thoughts

If you’re dealing with persistent Gravity Forms spam, start by reviewing the actual entries rather than immediately installing another plugin.

Look at the IP addresses and the content being submitted.

If the spam is consistently coming from one IP address, block it. If the IP addresses keep changing, look for patterns in the submissions themselves.

The basic process is:

  1. Open the spam submission in Gravity Forms.
  2. Check the sender’s IP address.
  3. Block repeat IP addresses using Wordfence when appropriate.
  4. Compare multiple spam entries for repeated content.
  5. Identify names, phrases, URLs, or domains associated with the spam.
  6. Add conditional logic to the Gravity Forms Submit button.
  7. Hide the Submit button when the spam condition is detected.
  8. Add an explanatory message if legitimate visitors could trigger the rule.
  9. Test both legitimate and blocked submissions.

It’s a simple technique, but for a persistent bot that keeps getting through your existing spam protection, it can be surprisingly effective.

Sometimes you don’t need to identify the bot or figure out where it’s coming from. You just need to make sure it can’t press Submit.

Calico Design is a premier web design and marketing agency in the Chicago and Tampa / St. Pete Florida areas. 

Explore Blog

Building a restaurant website in Elementor is usually pretty straightforward — until you get to the menu. A simple menu with an item name, description, and price isn’t difficult. But real restaurant menus aren’t always that simple. You start dealing with different...
*Note – this video is a bit old, plugins might look a little different, but the information is the same.   A WordPress contact form can appear to work perfectly while the most important part is quietly failing: the notification email never reaches...
Video can make a website look incredible, but it can also become one of the largest files a visitor has to download. This becomes especially important when you’re using autoplaying hero videos, background videos, animated graphics, event footage, or other video-heavy website...
A bigger email list isn’t always a better email list. Clean your lists, save on subscription fees, and show higher open rates! New to EmailOctopus? I switched from Mailchimp and pay half what I used to. Use my referral link to save $15...
What happens when you still have a complete WordPress website sitting on your hosting account, but you can no longer access it through the original domain? This can happen for several reasons. A client may have pointed their domain to a new...
Few things are more stressful than updating a WordPress plugin and suddenly seeing a “There has been a critical error on this website” message. Whether it is JetEngine, WooCommerce, Elementor, or another plugin, a fatal error can lock you out of your...