Creating the Difference

How to log booking IP address

Posted on: 16-05-2019 Last modified: 03-07-2021
Categories: HTML, JavaScript, PHP, Snippets Tags: ,

Be sure to mention you are logging the IP address in your Privacy Policy to be GDPR compliant.

This snippet only works for Events Manager Pro. The Forms Editor is one of the many great Pro features.

For security reasons you might want to be able to log the user’s IP address that was used during the booking. Events Manager Pro does not have this option by default. Luckily, it’s pretty easy to add this feature and still use it as a regular custom booking form field.

Step 1: Edit your existing Booking Form.

Add IP address field to EM Booking FormTo add a new custom field to your exisiting EM Bookings Form go to Events → Forms Editor and select your Booking Form. Add a new text field with the ID ‘ip_address’. You can name the label anything you want.

Step 2: Copy & paste the following snippet.

The snippet will automatically fetch the user’s current IP address, fill the text field and display it as a non-editable span. Add this to your functions.php:Click here to learn how to safely add your code to WordPress.

[php] function stonehenge_em_single_ticket_ipaddress() { // First, create a new EM Form Field: type = text, ID = ip_address. $ip = $_SERVER[‘REMOTE_ADDR’]; ?>; Step 3: Retrieving the saved value.

After the form has been submitted you can call its value just like any other custom booking field with the EM placeholder #_BOOKINGFORMCUSTOM{ip_address}.


⇐ Previous
Next ⇒