Hello,
You can use these functions in your child theme functions.php:
// Keep a log when a booking status changes
function my_theme_log_booking_status_changes( $booking_id, $state, $args ) {
$who = isset( $args[ 'is_admin' ] ) && ! $args[ 'is_admin' ] ? 'customer' : 'administrator';
$message = 'Booking #' . $booking_id . ' status changed to ' . $state . ' by ' . $who;
my_theme_add_log( $message );
}
add_action( 'bookacti_booking_state_changed', 'my_theme_log_booking_status_changes', 10, 3 );
// Keep a log when a booking group status changes
function my_theme_log_booking_group_status_changes( $booking_group_id, $state, $args ) {
$who = isset( $args[ 'is_admin' ] ) && ! $args[ 'is_admin' ] ? 'customer' : 'administrator';
$message = 'Booking group #' . $booking_group_id . ' status changed to ' . $state . ' by ' . $who;
my_theme_add_log( $message );
}
add_action( 'bookacti_booking_group_state_changed', 'my_theme_log_booking_group_status_changes', 10, 3 );
// Keep a log when a booking is rescheduled
function my_theme_log_booking_reschedules( $booking, $old_booking, $args ) {
$who = isset( $args[ 'is_admin' ] ) && ! $args[ 'is_admin' ] ? 'customer' : 'administrator';
$date_format= bookacti_get_message( 'date_format_long' );
$old_start = bookacti_format_datetime( $old_booking->event_start, $date_format );
$new_start = bookacti_format_datetime( $booking->event_end, $date_format );
$message = 'Booking #' . $booking->id . ' was rescheduled from ' . $old_start . ' to ' . $new_start . ' by ' . $who;
my_theme_add_log( $message );
}
add_action( 'bookacti_booking_rescheduled', 'my_theme_log_booking_reschedules', 10, 3 );
// Add a line in the log file
function my_theme_add_log( $message ) {
$file = WP_CONTENT_DIR . '/uploads/bookings-actions.log';
$handle = fopen( $file, 'a' );
$write = 0;
if( $handle !== false ) {
$time = date( 'c', time() );
$log = $time . ' - ' . $message . PHP_EOL;
$write = fwrite( $handle, $log );
fclose( $handle );
}
return $write;
}
It will write a log in a file that you can access in your browser at:
yoursite.com/wp-content/uploads/bookings-actions.log
each time a booking status changes or a booking is rescheduled.
Then, with CTRL+F you can look for “Booking #102” to find the logs related to the booking ID 102.
Regards,
Yoan Cutillas