Would you like to store the non-cached IP address in a Hidden Field with WPForms? The default {user_ip}
Smart Tag in WPForms pulls the IP address of the user who is completing your form. However, this IP address is captured at the time the user loads the page and could very well be a cached version.
In this tutorial, we’ll show you how to capture the uncached IP addresses of users filling out your form.
Creating Your Form
First, you’ll need to create a new form or edit an existing one to access the form builder. Once you’ve added all the necessary fields, add the Hidden Field to your form and note its ID.
Adding the Snippet to Capture the Uncached IP Address
Note: When using this snippet, you won’t need to use the {user_ip}
Smart Tag. This snippet will automatically get the user’s IP for you and place it in the Hidden Field while ensuring that the number captured will not be the cached version of the IP address.
Now, it’s time to add the snippet to your site. To proceed, copy and paste the code snippet below to your site. If you need any help adding snippets to your site, please see this tutorial.
The snippet above will only run on the form ID 727. If the field ID of 10 is indeed a Hidden Field, it will update this field after the form is submitted with the current user’s IP address.
Note: Make sure to replace the form ID and field ID with your actual IDs. If you need help finding your form and field IDs, please check out this tutorial.
That’s it! You’ve now learned how to capture the uncached IP address of users filling out your WordPress form.
Are you looking to add CSS animation to your form’s confirmation message? Check out our tutorial to learn how to add falling autumn leaves to your confirmation message.
Related
Filter Reference: wpforms_process_filter