Skip to main content

[QUESTION]Action Hook for getting Data

Hey fluent booking community, I have a short question. I know that we can use action hooks, so add actions hooks in for fluent form, but I don't find anything related to fluent booking. I'm just trying and erroring over the past 30-40 minutes, and it doesn't seem that there is a solution right now. So is there any wayβ€”I have pasted here some demo codeβ€”and is there any way to get this action hook running by PHP script in the background?

We have the option to add an action hook to a form itself, so I don't know whether it's also submitting the data from the booking. I would be more than happy to get feedback related to this action hook fetching thing, because otherwise I need to take this from the form with the action hook and a webhook from fluent booking, and I want to avoid any webhooks in the forms or other things. So it would be cool to do this with PHP.

Happy to get some ideas and suggestions.

Regards
Gerrit

<?php
/**
 * Simple FluentBooking Hook - No Errors
 */

// Only hook into the most reliable action
add_action('fluent_booking/after_creating_schedule', function($booking, $postedData, $calendarEvent) {

    // Simple logging first
    error_log('Booking created: ' . $booking->id);

    // Then update database
    $booking_data = [
        'unique_id' => 'booking_' . $booking->id,
        'object_name' => $booking->getBookingTitle(),
        'user_id' => get_current_user_id(),
        'user_name' => wp_get_current_user()->display_name,
        'action_type' => 'created_booking',
        'assigned_object' => 'booking',
        'assigned_object_id' => $booking->id,
        'guest_name' => $booking->first_name . ' ' . $booking->last_name,
        'guest_email' => $booking->email,
        'start_time' => $booking->start_time,
        'created_at' => current_time('mysql')
    ];

    // Insert into database
    global $wpdb;
    $wpdb->insert($wpdb->prefix . 'inkt_connect', $booking_data);

}, 10, 3);