The functionality in this snippet has been enhanced. I strongly recommend you use the “better” version: Better Limit Submission Per Time Period by User or IP
A visitor asked on the Limit User to One Submission Per Time Period snippet if it was possible to limit by the user’s IP address instead of their WordPress user ID. It is! This snippet is more useful for general usage since it doesn’t require visitors submitting the form to be registered users on your WordPress site.
View this code snippet on GitHub.How do I install this snippet?
Count to three. Then click the “Copy to Clipboard” link at the bottom of the snippet and paste the code into your theme’s functions.php file.
Do I need to configure this snippet to work with my form?
Only a few pieces! Here is an overview but the changes are notated inline in the code as well.
- Update
$gws_limit_message
to the message visitors should see when they have reached their submission limit. - Update
$gws_limit_time
to the amount of time the user must wait until they can submit the WordPress form again. This time must be provided in seconds. - Update the
5
in the filtergform_pre_render_5
to your own form ID.
Anything else?
You’re good to go! Be sure to check out the Limit User to One Submission Per Time Period snippet as well.