USP Pro provides settings and features to help prevent spam and other potential abuse. For example, you can configure a list of forbidden words and phrases that are not allowed in submitted posts. To stop spam, you can add a challenge question or Google reCaptcha to any USP Pro Form. And now, as of USP Pro version 4.3, it’s possible to block specific IP addresses from submitting post content.
Block IP addresses with USP Pro
USP Pro now provides a filter hook, usp_filter_ip_address
, that enables us to prevent any IP address from submitting posts. Simply add the following code to your WordPress-powered site:
function usp_filter_ip_address() {
return array('123.123.123', '111.222.121'); // these ip addresses are not allowed to submit posts
}
add_filter('usp_filter_ip_address', 'usp_filter_ip_address');
As written this code blocks the IP addresses 123.123.123
and 111.222.121
. Feel free to remove or replace as desired to block any IP address that should not be allowed to submit form content.
Bonus Tip
If you have email alerts enabled for the site admin, they will get a “Denied” alert each time the above function blocks a post submission.
%%ip_address%%
shortcut to the email-alert “denied” message to include the user’s IP address in the alert.