Hi @rousseauxy,
Can I clarify that when you say “webhook” do you mean you want your WordPress site to send a request to a remote URL when certain events happen?
I’d recommend that you hook into the rtb_send_notification_after
action. That would look like this:
add_action( 'rtb_send_notification_after', function( $notification ) {
$event = $notification->event; // eg - new_submission, or pending_to_confirmed
$booking = $notification->booking;
$args = [...your webhook payload...];
wp_remote_get('https://your-remote-web-hook.com', $args );
// you can use wp_remote_request if you need to send headers
} );
That will fire whenever an email notification is sent, and you may want to limit what events fire off the remote request. You can see all of the email notifications registered in the system here:
https://github.com/NateWr/restaurant-reservations/blob/master/includes/Notifications.class.php#L63-L73
Beware that this remote request will be completed before the booking request is returned to the user. So if IFTTT’s server takes 3 seconds to respond to your request, it will take 3 extra seconds to load the page after the user submits the booking form.
-
This reply was modified 5 years, 7 months ago by NateWr.