CodoBookings provides a comprehensive collection of WordPress hooks and filters that enable developers to extend and customize the booking system functionality. This guide covers all available CodoBookings Hooks and Filters with practical examples to help you integrate custom features seamlessly.
Dashboard and Admin Hooks:
codobookings_admin_overview_stats
This filter hook allows you to extend the dashboard widget with custom statistics and metrics for your booking system.
Example Usage:
add_filter('codobookings_admin_overview_stats', 'add_custom_booking_stats');
function add_custom_booking_stats($stats) {
$stats['revenue'] = array(
'label' => 'Total Revenue',
'value' => '$5,230',
'icon' => 'dashicons-money-alt'
);
return $stats;
}
Single Calendar Display Hooks:
These hooks provide granular control over the single calendar view, allowing you to customize every aspect of the calendar display page.
codobookings_before_calendar
This action hook fires immediately before a calendar is displayed, perfect for adding custom content or initializing scripts.
Example Usage:
add_action('codobookings_before_calendar', 'add_calendar_notice');
function add_calendar_notice($calendar_id) {
echo '<div class="custom-notice">Book your appointment today!</div>';
}
codobookings_after_calendar
This action hook fires after a calendar is rendered, ideal for adding promotional content or related information.
Example Usage:
add_action('codobookings_after_calendar', 'add_calendar_footer');
function add_calendar_footer($calendar_id) {
echo '<p class="calendar-info">Questions? Contact us at support@example.com</p>';
}
codobookings_before_calendar_container
This action hook fires before the entire calendar container wrapper, ideal for adding page-level notices or tracking code.
Example Usage:
php
add_action('codobookings_before_calendar_container', 'add_calendar_page_notice', 10, 2);
function add_calendar_page_notice($calendar_id, $calendar_post) {
echo '<div class="site-notice">📅 Book your appointment with confidence!</div>';
}
codobookings_after_calendar_container
This action hook fires after the entire calendar container, perfect for adding related content or social sharing buttons.
Example Usage:
add_action('codobookings_after_calendar_container', 'add_social_sharing', 10, 2);
function add_social_sharing($calendar_id, $calendar_post) {
$title = get_the_title($calendar_id);
$url = get_permalink($calendar_id);
echo '<div class="share-buttons">';
echo '<a href="https://twitter.com/intent/tweet?text=' . urlencode($title) . '&url=' . urlencode($url) . '" target="_blank">Share on Twitter</a>';
echo '</div>';
}
codobookings_calendar_container_start
This action hook fires at the very start of the calendar container content, useful for adding container-level wrappers.
Example Usage:
add_action('codobookings_calendar_container_start', 'add_analytics_wrapper', 10, 2);
function add_analytics_wrapper($calendar_id, $calendar_post) {
echo '<div class="analytics-tracking" data-calendar-type="' . esc_attr(get_post_meta($calendar_id, '_calendar_type', true)) . '">';
}
codobookings_calendar_container_end
This action hook fires at the end of the calendar container content, ideal for closing custom wrappers.
Example Usage:
add_action('codobookings_calendar_container_end', 'close_analytics_wrapper');
function close_analytics_wrapper($calendar_id, $calendar_post) {
echo '</div><!-- .analytics-tracking -->';
}
codobookings_before_back_button
This action hook fires before the back button is displayed, useful for adding breadcrumbs or navigation aids.
Example Usage:
add_action('codobookings_before_back_button', 'add_breadcrumbs', 10, 2);
function add_breadcrumbs($back_url, $calendar_id) {
echo '<nav class="breadcrumbs">';
echo '<a href="' . home_url() . '">Home</a> > ';
echo '<a href="' . esc_url($back_url) . '">Services</a> > ';
echo '<span>' . get_the_title($calendar_id) . '</span>';
echo '</nav>';
}
codobookings_after_back_button
This action hook fires after the back button, perfect for adding alternative navigation options.
Example Usage:
add_action('codobookings_after_back_button', 'add_quick_links', 10, 2);
function add_quick_links($back_url, $calendar_id) {
echo '<div class="quick-links">';
echo '<a href="/contact">Need Help?</a> | ';
echo '<a href="/faq">FAQ</a>';
echo '</div>';
}
codobookings_calendar_back_url
This filter hook modifies the back button URL, allowing dynamic URL generation based on context.
Example Usage:
add_filter('codobookings_calendar_back_url', 'custom_back_url', 10, 3);
function custom_back_url($back_url, $back_id, $calendar_id) {
// Add tracking parameters to back URL
return add_query_arg(array(
'viewed' => $calendar_id,
'source' => 'calendar'
), $back_url);
}
codobookings_calendar_back_button_text
This filter hook customizes the back button text based on calendar type or other conditions.
Example Usage:
add_filter('codobookings_calendar_back_button_text', 'custom_back_text', 10, 2);
function custom_back_text($button_text, $calendar_id) {
$calendar_type = get_post_meta($calendar_id, '_calendar_type', true);
if ($calendar_type === 'consultation') {
return __('← Back to Consultations', 'codobookings');
}
return $button_text;
}
codobookings_single_calendar_start
This action hook fires at the beginning of the single calendar content wrapper, ideal for adding calendar-specific notices.
Example Usage:
add_action('codobookings_single_calendar_start', 'add_calendar_badge', 10, 2);
function add_calendar_badge($calendar_id, $calendar_post) {
$is_featured = get_post_meta($calendar_id, '_is_featured', true);
if ($is_featured) {
echo '<div class="featured-badge">⭐ Featured Service</div>';
}
}
codobookings_single_calendar_end
This action hook fires at the end of the single calendar content wrapper, perfect for adding testimonials or related services.
Example Usage:
add_action('codobookings_single_calendar_end', 'add_testimonials', 10, 2);
function add_testimonials($calendar_id, $calendar_post) {
$testimonial = get_post_meta($calendar_id, '_customer_testimonial', true);
if ($testimonial) {
echo '<div class="testimonial">';
echo '<p>"' . esc_html($testimonial) . '"</p>';
echo '</div>';
}
}
codobookings_before_calendar_featured_image
This action hook fires before the featured image is displayed, useful for adding image overlays or captions.
Example Usage:
add_action('codobookings_before_calendar_featured_image', 'add_image_caption');
function add_image_caption($calendar_id) {
$caption = get_post_meta($calendar_id, '_image_caption', true);
if ($caption) {
echo '<div class="image-caption-top">' . esc_html($caption) . '</div>';
}
}
codobookings_after_calendar_featured_image
This action hook fires after the featured image, perfect for adding image credits or additional media.
Example Usage:
add_action('codobookings_after_calendar_featured_image', 'add_video_tour');
function add_video_tour($calendar_id) {
$video_url = get_post_meta($calendar_id, '_video_tour_url', true);
if ($video_url) {
echo '<div class="video-tour">';
echo '<a href="' . esc_url($video_url) . '" class="play-video">▶ Watch Video Tour</a>';
echo '</div>';
}
}
codobookings_calendar_featured_image
This filter hook modifies the featured image HTML, allowing complete control over image rendering.
Example Usage:
add_filter('codobookings_calendar_featured_image', 'customize_featured_image', 10, 2);
function customize_featured_image($image_html, $calendar_id) {
// Wrap image in a lightbox link
$full_image = wp_get_attachment_image_src(get_post_thumbnail_id($calendar_id), 'full');
if ($full_image) {
return '<a href="' . esc_url($full_image[0]) . '" class="lightbox">' . $image_html . '</a>';
}
return $image_html;
}
codobookings_before_calendar_title
This action hook fires before the calendar title, useful for adding category badges or labels.
Example Usage:
add_action('codobookings_before_calendar_title', 'add_category_badge');
function add_category_badge($calendar_id) {
$terms = get_the_terms($calendar_id, 'codo_calendar_category');
if ($terms && !is_wp_error($terms)) {
$category = $terms[0];
echo '<span class="category-badge">' . esc_html($category->name) . '</span>';
}
}
codobookings_after_calendar_title
This action hook fires after the calendar title, perfect for adding ratings or metadata.
Example Usage:
add_action('codobookings_after_calendar_title', 'add_rating_stars');
function add_rating_stars($calendar_id) {
$rating = get_post_meta($calendar_id, '_average_rating', true);
if ($rating) {
echo '<div class="star-rating">';
echo str_repeat('⭐', intval($rating)) . ' (' . esc_html($rating) . '/5)';
echo '</div>';
}
}
codobookings_calendar_title
This filter hook modifies the calendar title display, allowing dynamic title generation.
Example Usage:
add_filter('codobookings_calendar_title', 'add_duration_to_title', 10, 2);
function add_duration_to_title($title, $calendar_id) {
$duration = get_post_meta($calendar_id, '_session_duration', true);
if ($duration) {
return $title . ' (' . $duration . ' minutes)';
}
return $title;
}
codobookings_before_calendar_description
This action hook fires before the calendar description, useful for adding promotional notices.
Example Usage:
add_action('codobookings_before_calendar_description', 'add_promo_banner');
function add_promo_banner($calendar_id) {
$has_discount = get_post_meta($calendar_id, '_has_discount', true);
if ($has_discount) {
echo '<div class="promo-banner">🎉 Special Discount Available!</div>';
}
}
codobookings_after_calendar_description
This action hook fires after the calendar description, perfect for adding pricing information or key features.
Example Usage:
add_action('codobookings_after_calendar_description', 'add_key_features');
function add_key_features($calendar_id) {
$features = get_post_meta($calendar_id, '_key_features', true);
if ($features && is_array($features)) {
echo '<ul class="key-features">';
foreach ($features as $feature) {
echo '<li>✓ ' . esc_html($feature) . '</li>';
}
echo '</ul>';
}
}
codobookings_calendar_description
This filter hook modifies the calendar description content before display.
Example Usage:
add_filter('codobookings_calendar_description', 'add_instructor_info', 10, 2);
function add_instructor_info($description, $calendar_id) {
$instructor = get_post_meta($calendar_id, '_instructor_name', true);
if ($instructor) {
$description .= '<p class="instructor"><strong>Instructor:</strong> ' . esc_html($instructor) . '</p>';
}
return $description;
}
codobookings_calendar_wrapper_start
This action hook fires at the start of the calendar wrapper div, useful for adding loading overlays or status indicators.
Example Usage:
add_action('codobookings_calendar_wrapper_start', 'add_availability_status');
function add_availability_status($calendar_id) {
$availability = get_post_meta($calendar_id, '_current_availability', true);
if ($availability === 'limited') {
echo '<div class="availability-warning">⚠️ Limited slots available</div>';
}
}
codobookings_calendar_wrapper_end
This action hook fires at the end of the calendar wrapper div, perfect for adding tooltips or help text.
Example Usage:
add_action('codobookings_calendar_wrapper_end', 'add_booking_help');
function add_booking_help($calendar_id) {
echo '<div class="booking-help">';
echo '<p>💡 <strong>Tip:</strong> Click on any available time slot to proceed with booking.</p>';
echo '</div>';
}
codobookings_calendar_wrapper_classes
This filter hook adds or modifies CSS classes on the calendar wrapper element.
Example Usage:
add_filter('codobookings_calendar_wrapper_classes', 'add_custom_calendar_classes', 10, 2);
function add_custom_calendar_classes($classes, $calendar_id) {
$calendar_type = get_post_meta($calendar_id, '_calendar_type', true);
$classes[] = 'calendar-type-' . sanitize_html_class($calendar_type);
if (get_post_meta($calendar_id, '_is_premium', true)) {
$classes[] = 'premium-calendar';
}
return $classes;
}
codobookings_calendar_loading_message
This filter hook customizes the loading message displayed while the calendar initializes.
Example Usage:
add_filter('codobookings_calendar_loading_message', 'custom_loading_message', 10, 2);
function custom_loading_message($message, $calendar_id) {
$calendar_name = get_the_title($calendar_id);
return sprintf(__('Loading %s calendar, please wait...', 'codobookings'), $calendar_name);
}
codobookings_confirmation_message
This filter hook modifies the booking confirmation message shown to users after successful booking.
Example Usage:
add_filter('codobookings_confirmation_message', 'personalized_confirmation', 10, 2);
function personalized_confirmation($message, $calendar_id) {
$calendar_name = get_the_title($calendar_id);
$custom_message = get_post_meta($calendar_id, '_custom_confirmation', true);
if ($custom_message) {
return $custom_message;
}
return sprintf(
__('Thank you for booking %s! Check your email for confirmation details.', 'codobookings'),
$calendar_name
);
}
Calendar Grid Display Hooks:
codobookings_before_calendars_grid
This action hook fires before the calendar grid layout is displayed, useful for adding grid-wide notices or filters.
Example Usage:
add_action('codobookings_before_calendars_grid', 'add_grid_header');
function add_grid_header() {
echo '<div class="grid-header"><h2>Available Services</h2></div>';
}
codobookings_after_calendars_grid
This action hook fires after the calendar grid is rendered, perfect for adding pagination or additional navigation.
Example Usage:
add_action('codobookings_after_calendars_grid', 'add_grid_footer');
function add_grid_footer() {
echo '<div class="grid-footer"><a href="/all-services">View All Services</a></div>';
}
codobookings_grid_query_args
This filter hook modifies the query arguments used to retrieve calendars for the grid display.
Example Usage:
add_filter('codobookings_grid_query_args', 'filter_grid_calendars');
function filter_grid_calendars($args) {
$args['posts_per_page'] = 6;
$args['orderby'] = 'menu_order';
return $args;
}
codobookings_show_calendar_in_grid
This filter hook controls whether a specific calendar appears in the grid layout based on custom conditions.
Example Usage:
add_filter('codobookings_show_calendar_in_grid', 'hide_inactive_calendars', 10, 2);
function hide_inactive_calendars($show, $calendar_id) {
$is_active = get_post_meta($calendar_id, '_calendar_active', true);
return $is_active === 'yes';
}
Calendar Grid Item Hooks:
codobookings_before_calendar_grid_item
This action hook fires before each individual calendar item in the grid is rendered.
Example Usage:
add_action('codobookings_before_calendar_grid_item', 'add_item_wrapper_start');
function add_item_wrapper_start($calendar_id) {
echo '<div class="custom-grid-wrapper">';
}
codobookings_after_calendar_grid_item
This action hook fires after each calendar grid item, useful for closing custom wrappers or adding separators.
Example Usage:
add_action('codobookings_after_calendar_grid_item', 'add_item_wrapper_end');
function add_item_wrapper_end($calendar_id) {
echo '</div>';
}
codobookings_calendar_grid_item_content_start
This action hook fires at the beginning of the grid item content area, perfect for adding badges or labels.
Example Usage:
add_action('codobookings_calendar_grid_item_content_start', 'add_popular_badge');
function add_popular_badge($calendar_id) {
$is_popular = get_post_meta($calendar_id, '_is_popular', true);
if ($is_popular) {
echo '<span class="badge-popular">Most Popular</span>';
}
}
codobookings_calendar_grid_item_content_end
This action hook fires at the end of grid item content, ideal for adding pricing or availability information.
Example Usage:
add_action('codobookings_calendar_grid_item_content_end', 'add_price_tag');
function add_price_tag($calendar_id) {
$price = get_post_meta($calendar_id, '_service_price', true);
if ($price) {
echo '<div class="price-tag">Starting at $' . esc_html($price) . '</div>';
}
}
codobookings_calendar_grid_item_before_button
This action hook fires immediately before the booking button, useful for adding disclaimers or icons.
Example Usage:
add_action('codobookings_calendar_grid_item_before_button', 'add_availability_text');
function add_availability_text($calendar_id) {
echo '<p class="availability-text">✓ Available Today</p>';
}
codobookings_calendar_details_url
This filter hook modifies the URL that users navigate to when clicking a calendar grid item.
Example Usage:
add_filter('codobookings_calendar_details_url', 'custom_details_url', 10, 2);
function custom_details_url($url, $calendar_id) {
return add_query_arg('source', 'grid', $url);
}
codobookings_grid_button_text
This filter hook customizes the button text for each calendar in the grid, allowing per-calendar variations.
Example Usage:
add_filter('codobookings_grid_button_text', 'custom_button_text', 10, 2);
function custom_button_text($text, $calendar_id) {
$calendar_type = get_post_meta($calendar_id, '_calendar_type', true);
return $calendar_type === 'consultation' ? 'Schedule Consultation' : 'Book Now';
}
codobookings_no_calendars_message
This filter hook customizes the message displayed when no calendars are available in the grid.
Example Usage:
add_filter('codobookings_no_calendars_message', 'custom_no_calendars_message');
function custom_no_calendars_message($message) {
return '<p>No services available at the moment. Please check back soon!</p>';
}
Booking Process Hooks
codobookings_before_booking_insert
This filter hook fires before a booking is saved to the database, allowing validation or data modification.
Example Usage:
add_filter('codobookings_before_booking_insert', 'validate_booking_data');
function validate_booking_data($booking_data) {
if (empty($booking_data['phone'])) {
wp_die('Phone number is required for bookings.');
}
return $booking_data;
}
codobookings_booking_created
This action hook triggers immediately after a new booking is successfully created in the database.
Example Usage:
add_action('codobookings_booking_created', 'send_sms_notification');
function send_sms_notification($booking_id) {
$booking = get_post($booking_id);
$phone = get_post_meta($booking_id, '_customer_phone', true);
// Send SMS using your preferred service
send_sms($phone, 'Your booking has been confirmed!');
}
codobookings_booking_status_changed
This action hook fires when a booking status is updated, useful for triggering status-specific workflows.
Example Usage:
add_action('codobookings_booking_status_changed', 'handle_status_change', 10, 3);
function handle_status_change($booking_id, $old_status, $new_status) {
if ($new_status === 'confirmed') {
// Add booking to external calendar system
sync_to_external_calendar($booking_id);
}
}
codobookings_emails_sent
This action hook fires after a booking confirmation email is successfully sent to the customer.
Example Usage:
add_action('codobookings_emails_sent', 'log_email_sent');
function log_email_sent($booking_id) {
error_log('Confirmation email sent for booking #' . $booking_id);
update_post_meta($booking_id, '_email_sent_time', current_time('mysql'));
}
codobookings_status_email_sent
This action hook fires when a status change notification email is sent to the customer.
Example Usage:
add_action('codobookings_status_email_sent', 'track_status_email', 10, 2);
function track_status_email($booking_id, $status) {
$log = get_post_meta($booking_id, '_email_log', true) ?: array();
$log[] = array('status' => $status, 'time' => current_time('mysql'));
update_post_meta($booking_id, '_email_log', $log);
}
Design Customization Hooks:
codobookings_design_fields
This filter hook adds or modifies design settings fields in the CodoBookings design panel.
Example Usage:
add_filter('codobookings_design_fields', 'add_custom_design_fields');
function add_custom_design_fields($fields) {
$fields['header_shadow'] = array(
'type' => 'checkbox',
'label' => 'Enable Header Shadow',
'section' => 'general',
'default' => false
);
return $fields;
}
codobookings_design_sections
This filter hook adds or modifies the sections displayed in the design settings page.
Example Usage:
add_filter('codobookings_design_sections', 'add_custom_design_section');
function add_custom_design_section($sections) {
$sections['branding'] = array(
'title' => 'Branding Options',
'description' => 'Customize your brand appearance'
);
return $sections;
}
codobookings_design_field_value_{$field_id}
This dynamic filter hook modifies a specific field value before it’s rendered in the design settings.
Example Usage:
add_filter('codobookings_design_field_value_primary_color', 'override_primary_color');
function override_primary_color($value) {
if (is_user_logged_in() && current_user_can('administrator')) {
return $value; // Admins see actual value
}
return '#3498db'; // Others see default
}
codobookings_before_design_settings
This action hook fires before the design settings form, ideal for adding preset selectors or import options.
Example Usage:
add_action('codobookings_before_design_settings', 'add_design_presets');
function add_design_presets() {
echo '<div class="design-presets">';
echo '<button class="preset-btn" data-preset="modern">Modern</button>';
echo '<button class="preset-btn" data-preset="classic">Classic</button>';
echo '</div>';
}
codobookings_after_design_settings
This action hook fires after the design settings form, perfect for adding reset buttons or export functionality.
Example Usage:
add_action('codobookings_after_design_settings', 'add_reset_button');
function add_reset_button() {
echo '<button type="button" class="button button-secondary" id="reset-design">';
echo 'Reset to Defaults</button>';
}
codobookings_before_design_section_{$section_id}
This dynamic action hook fires before each specific design section is rendered.
Example Usage:
add_action('codobookings_before_design_section_colors', 'add_color_section_tip');
function add_color_section_tip() {
echo '<div class="section-tip">💡 Choose colors that match your brand identity.</div>';
}
codobookings_after_design_section_{$section_id}
This dynamic action hook fires after a specific design section, useful for section-specific controls.
Example Usage:
add_action('codobookings_after_design_section_typography', 'add_font_preview');
function add_font_preview() {
echo '<div class="font-preview">The quick brown fox jumps over the lazy dog</div>';
}
codobookings_before_design_field_{$field_id}
This dynamic action hook fires before an individual design field is rendered.
Example Usage:
add_action('codobookings_before_design_field_primary_color', 'add_color_picker_tip');
function add_color_picker_tip() {
echo '<small class="field-tip">This color will be used for buttons and links.</small>';
}
codobookings_after_design_field_{$field_id}
This dynamic action hook fires after a specific design field, ideal for field-specific help text.
Example Usage:
add_action('codobookings_after_design_field_font_size', 'add_font_size_warning');
function add_font_size_warning() {
echo '<small class="warning">⚠️ Very small fonts may affect readability.</small>';
}
codobookings_render_design_field_{$field_type}
This dynamic action hook provides custom rendering for specific field types in the design settings.
Example Usage:
add_action('codobookings_render_design_field_gradient', 'render_gradient_field', 10, 2);
function render_gradient_field($field, $value) {
echo '<div class="gradient-picker">';
echo '<input type="text" name="' . esc_attr($field['id']) . '_start" value="' . esc_attr($value['start']) . '">';
echo '<input type="text" name="' . esc_attr($field['id']) . '_end" value="' . esc_attr($value['end']) . '">';
echo '</div>';
}
Styling and CSS Hooks:
codobookings_theme_colors
This filter hook provides or modifies theme colors that can be inherited by calendar styling.
Example Usage:
add_filter('codobookings_theme_colors', 'add_theme_colors');
function add_theme_colors($colors) {
$colors['accent'] = '#e74c3c';
$colors['success'] = '#2ecc71';
return $colors;
}
codobookings_css_variables
This filter hook adds or modifies CSS custom properties (variables) used in calendar styling.
Example Usage:
add_filter('codobookings_css_variables', 'add_custom_css_vars');
function add_custom_css_vars($variables) {
$variables['--calendar-border-radius'] = '8px';
$variables['--calendar-shadow'] = '0 2px 10px rgba(0,0,0,0.1)';
return $variables;
}
codobookings_dynamic_css
This filter hook modifies the final generated CSS output before it’s rendered on the page.
Example Usage:
add_filter('codobookings_dynamic_css', 'add_custom_calendar_css');
function add_custom_calendar_css($css) {
$css .= '
.codobookings-calendar {
animation: fadeIn 0.3s ease-in;
}
@keyframes fadeIn {
from { opacity: 0; }
to { opacity: 1; }
}';
return $css;
}
codobookings_core_variable_styles
This filter hook modifies core CSS styles that utilize CSS variables for dynamic theming.
Example Usage:
add_filter('codobookings_core_variable_styles', 'customize_core_styles');
function customize_core_styles($styles) {
$styles['button'] = 'background: var(--primary-color);
border: 2px solid var(--primary-color);
transition: all 0.3s ease;';
return $styles;
}
codobookings_is_calendar_page
This filter hook determines whether the current page should load calendar-specific styles and scripts.
Example Usage:
add_filter('codobookings_is_calendar_page', 'detect_calendar_pages');
function detect_calendar_pages($is_calendar_page) {
if (is_page('services') || is_page('booking')) {
return true;
}
return $is_calendar_page;
}
codobookings_enqueue_design_assets
This action hook allows enqueueing additional design-related scripts and stylesheets.
Example Usage:
add_action('codobookings_enqueue_design_assets', 'enqueue_custom_calendar_assets');
function enqueue_custom_calendar_assets() {
wp_enqueue_style('custom-calendar-animations',
get_stylesheet_directory_uri() . '/css/calendar-animations.css');
}
JavaScript Hooks
CodoBookings provides JavaScript hooks accessible through window.CodoBookings.hooks for client-side customization.
beforeConfirmBooking
This JavaScript hook fires before processing a booking request from the user.
Example Usage:
window.CodoBookings.hooks.addAction('beforeConfirmBooking', function(bookingData) {
console.log('Booking about to be confirmed:', bookingData);
// Add custom validation
if (!bookingData.email.includes('@')) {
alert('Please enter a valid email address');
return false;
}
});
afterConfirmBooking
This JavaScript hook fires after the booking request has been processed successfully.
Example Usage:
window.CodoBookings.hooks.addAction('afterConfirmBooking', function(response) {
console.log('Booking confirmed:', response);
// Track conversion in analytics
gtag('event', 'booking_completed', {
'event_category': 'bookings',
'booking_id': response.booking_id
});
});
beforeCreateBooking
This JavaScript hook fires before a booking creation request is sent to the server.
Example Usage:
window.CodoBookings.hooks.addAction('beforeCreateBooking', function(bookingData) {
// Add UTM parameters to booking
bookingData.utm_source = new URLSearchParams(window.location.search).get('utm_source');
bookingData.utm_campaign = new URLSearchParams(window.location.search).get('utm_campaign');
return bookingData;
});
afterCreateBooking
This JavaScript hook fires after a booking has been successfully created on the server.
Example Usage:
window.CodoBookings.hooks.addAction('afterCreateBooking', function(booking) {
// Show custom success message
const message = document.createElement('div');
message.className = 'custom-success-notification';
message.textContent = 'Thank you! Your booking #' + booking.id + ' has been confirmed.';
document.body.appendChild(message);
});
beforeCalendarReload
This JavaScript hook fires before a calendar is reloaded, useful for showing loading states.
Example Usage:
window.CodoBookings.hooks.addAction('beforeCalendarReload', function(calendarId) {
const calendar = document.querySelector('#calendar-' + calendarId);
calendar.classList.add('loading');
calendar.insertAdjacentHTML('beforeend', '<div class="spinner">Loading...</div>');
});
afterCalendarReload
This JavaScript hook fires after a calendar has been reloaded with new data.
Example Usage:
window.CodoBookings.hooks.addAction('afterCalendarReload', function(calendarId) {
const calendar = document.querySelector('#calendar-' + calendarId);
calendar.classList.remove('loading');
const spinner = calendar.querySelector('.spinner');
if (spinner) spinner.remove();
});
afterSidebarRender
This JavaScript hook fires after the calendar sidebar with time slots has been rendered.
Example Usage:
window.CodoBookings.hooks.addAction('afterSidebarRender', function(sidebar) {
// Add custom tooltip to time slots
const slots = sidebar.querySelectorAll('.time-slot');
slots.forEach(slot => {
slot.setAttribute('title', 'Click to book this time slot');
});
});
Conclusion
CodoBookings hooks and filters provide extensive customization capabilities for WordPress developers. By leveraging these hooks, you can extend booking functionality, customize the user experience, integrate with third-party services, and create a booking system perfectly tailored to your specific requirements.
For optimal implementation, always test your custom code thoroughly and follow WordPress coding standards. Use appropriate hook priorities when multiple functions hook into the same action or filter, and ensure your customizations don’t conflict with core plugin functionality.
