Action
uncanny-automator-pro
mec_booking_pended
Fires when a booking's status is changed to pending.
add_action( 'mec_booking_pended', $callback, 10, 1 );
Description
Fires after a Modern Events Calendar booking is set to a pending status. Developers can use this hook to perform custom actions on pending bookings, such as triggering notifications or updating related data. The booking ID is passed as an argument.
Usage
add_action( 'mec_booking_pended', 'your_function_name', 10, 1 );
Parameters
-
$booking_id(mixed) - This parameter contains the unique identifier for the booking that has been pended.
Examples
add_action( 'mec_booking_pended', 'my_mec_handle_pending_booking', 10, 1 );
/**
* Example function to handle a pending booking from Modern Events Calendar.
* This could be used to send a custom notification, update a related post,
* or perform other custom actions when a booking is initially pended.
*
* @param int $booking_id The ID of the booking that has been pended.
*/
function my_mec_handle_pending_booking( $booking_id ) {
// Ensure the booking ID is valid.
if ( ! $booking_id || ! is_numeric( $booking_id ) ) {
return;
}
// Retrieve booking details.
$booking = MECSingletonBookingSingleton::get_booking( $booking_id );
// Check if booking details were successfully retrieved.
if ( ! $booking ) {
error_log( "my_mec_handle_pending_booking: Could not retrieve booking details for ID: {$booking_id}" );
return;
}
// Example: Log the pending booking event for debugging.
error_log( "MEC Booking Pended: Booking ID {$booking_id} for event ID {$booking->get_event_id()} is now pending." );
// Example: If you wanted to add a custom status or flag to the booking post meta.
// Replace 'my_custom_pending_flag' with your desired meta key.
// The value '1' is just an example; you might store more complex data.
update_post_meta( $booking_id, 'my_custom_pending_flag', true );
// Example: You could also fetch event details and perform logic based on them.
// $event = MECEvent::get_event_details( $booking->get_event_id() );
// if ( $event && isset( $event['label'] ) && $event['label'] === 'Special Event' ) {
// error_log( "Special Event booking pended: {$booking_id}" );
// // Perform specific actions for special events
// }
// Note: If this were a filter hook, you would need to return a value.
// For example: return $some_modified_data;
}
Placement
This code should be placed in the functions.php file of your active theme, a custom plugin, or using a code snippets plugin.
Source Code
uncanny-automator-pro/src/integrations/modern-events-calendar/actions/mec-book-user.php:223
update_post_meta( $booking_id, 'mec_gateway', self::GATEWAY );
update_post_meta( $booking_id, 'mec_gateway_label', $gateway->title() );
// For Booking Badge
update_post_meta( $booking_id, 'mec_book_date_submit', gmdate( 'YmdHis', time() ) );
// Execute pending action.
do_action( 'mec_booking_pended', $booking_id );
// Send notification if its a new booking.
try {
if ( $this->is_new_booking( $booking_id ) ) {
do_action( 'mec_booking_completed', $booking_id );