• Resolved lapd

    (@lapd)


    Hi!

    Is it possible with this plugin to collect and store IP address of a user when he/she makes a booking? It would be great if the IP address would be displayed next to the booking date and time in reservations section in the control panel. If not, I think it would be fine as long as this information is stored in database. We need this to comply with GDPR.

    Regards,
    Matej

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Support angelo_nwl

    (@angelo_nwl)

    hi,

    sorry but at the moment this is not yet possible and might need custom coding on your part to make this work.

    You need to create a custom placeholder for that.

    
    /* === Display User IP Address === */
    function em_custom_placeholder_booking_ip($replacement, $EM_Booking, $result) {
        if(is_object($EM_Booking)) {
    		if($result == '#_ccUserIP') {
    			if(!empty($_SERVER['HTTP_CLIENT_IP'])) { $ip = $_SERVER['HTTP_CLIENT_IP']; }
    			elseif(!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { $ip = $_SERVER['HTTP_X_FORWARDED_FOR']; } 
    			else { $ip = $_SERVER['REMOTE_ADDR']; }
    			$replacement = $ip; 
    		}
    	}
    return $replacement;
    }
    add_filter('em_event_output_placeholder', 'em_custom_placeholder_booking_ip', 1, 3 );
    

    Then, if you want to display it on the booking form as well (you need to show what data you collect), add this to your ticket-single.php template file:

    <div class="form-group">
    	<label><?php echo __('IP Address','stonehenge-theme'); ?></label>
    	<span><?php echo $EM_Event->output("#_ccUserIP"); ?></span>
    </div>

    This way you can use the #_ccUserIP placeholder anywhere in Events Manager, so in emails as well.

    To see it in action: https://www.gidspatrick.nl/agenda/ (In Dutch, but you get the idea the booking form anyway, hehehe) 😉

    Thread Starter lapd

    (@lapd)

    Wow, that works!

    I really appreciate your help.
    And you have a good looking form on your website as well!

    Regards,
    Matej

    Glad I could help, Matej. 🙂
    And thanks.. Took me a while to get the styling just right (and responsive), but it was worth it. Especially getting the checkbox leeft of the label was quite a challenge. 😉

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Get IP address when user makes a booking’ is closed to new replies.