This article refers to version 1.10.45+ of WS Form PRO.
Spam form submissions are a common problem for many websites. Whether it is a contact form, registration page, or support request, repeated spam from specific sources can quickly become disruptive.
WS Form includes built-in tools to help prevent this. One effective method is blocking specific IP addresses. This allows you to prevent submissions from individual users who are abusing your forms.
There are two main ways to block IPs in WS Form:
- IP Blocklist setting in Form Settings
- The wsf_submit_block_ips filter hook
How to Use the IP Blocklist Setting in WS Form
You can block IP addresses directly from the WordPress admin without writing any code.
To enable IP blocking:
- Edit your form in WS Form.
- Click the Form Settings icon in the layout editor.
- Go to the Spam tab.
- Enable the IP Blocklist setting.
- Click the + icon to add the IP addresses you want to block.
- (Optional) Set a custom error message to show blocked users.
Once saved, WS Form will prevent submissions from any IP you list. You can manage this list separately for each form.
IP Blocking with a Filter Hook
Developers can block IPs programmatically using the wsf_submit_block_ips filter hook.
Here is an example:
add_filter('wsf_submit_block_ips', function($ips, $form, $submit) { $ips[] = '203.0.113.45'; $ips[] = '198.51.100.22'; return $ips; }, 10, 3);
This method is useful if you want to apply the same IP blocklist across multiple forms or pull the list from an external source.
Customize the Message Shown to Blocked Users
You can change the message that appears when an IP is blocked by using the wsf_submit_block_ips_message filter hook:
add_filter('wsf_submit_block_ips_message', function($message, $form, $submit) { return __('Access to this form has been blocked for your IP address.'); }, 10, 3);
This message overrides the default error message and supports full localization.
Why Block IP Addresses in WordPress Forms?
Blocking IPs is a targeted way to stop specific individuals from misusing your forms. It gives you more control over repeated abuse than general spam filters alone.
Common reasons to block an IP:
- A user is flooding your form with submissions
- You receive repeated spam from the same address
- You want to manually restrict access to a private or internal form
Final Thoughts
Blocking IP addresses in WS Form is a simple but effective way to reduce spam and control who can access your WordPress forms. It is easy to configure, customizable, and works immediately once enabled.
If you are getting spam from multiple IP addresses, consider employing some of the other spam prevention features of WS Form, including:
Each feature addresses a different type of threat. Together, they can form a strong, multi-layered defense.
To learn more: