Created
February 15, 2021 16:09
-
-
Save chetanmadaan/8bef06c8b036d590f0554fe987377b69 to your computer and use it in GitHub Desktop.
Post to WebHook on event booking/registration for eventsmanagerpro WP
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function my_offline_auto_approve_filter( $result, $EM_Booking ){ | |
$event = [ | |
'eventname' => $EM_Booking->event->event_name, | |
'event_id' => $EM_Booking->event->event_id, | |
'post_id' => $EM_Booking->event->post_id, | |
'post_content' => $EM_Booking->event->post_content, | |
'start_time' => $EM_Booking->event->start_time, | |
'start_date' => $EM_Booking->event->start_date, | |
'end_date' => $EM_Booking->event->end_date, | |
'end_time' => $EM_Booking->event->end_time, | |
'booking_id' => $EM_Booking->id | |
]; | |
$fields = [ | |
"BookInginfo" => $EM_Booking->booking_meta, | |
"Event" => $event | |
//"LastName" => $EM_Booking->booking_meta->registration->last_name | |
]; | |
$data_string = json_encode($fields); | |
$ch = curl_init('https://hooks.zapier.com/hooks/catch/xxxx/xxxx/'); | |
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); | |
curl_setopt($ch, CURLOPT_POSTFIELDS,$data_string); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | |
curl_setopt($ch, CURLOPT_HTTPHEADER, array( | |
'Content-Type: application/json', | |
'Content-Length: ' . strlen($data_string)) | |
); | |
$result = curl_exec($ch); | |
//curl_close($ch); | |
//exit(); | |
return $result; | |
} | |
add_filter('em_booking_save', 'my_offline_auto_approve_filter', 100, 2); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment