Skip to main content

Documentation

In this documentation, you will find all the important information about the plugin – from installation and configuration to usage and extension.

Hooks

In this post, we’ll walk you through:


Bookings

The following action hooks can be used to react to booking status changes:

add_action('cevento/booking_received', function ($event, $booking) {
    // Execute something when a new booking is received
}, 10, 2);

add_action('cevento/booking_confirmed', function ($event, $booking) {
    // Execute something when the booking is confirmed
}, 10, 2);

add_action('cevento/booking_cancel', function ($event, $booking) {
    // Execute something when the booking is cancelled
}, 10, 2);

Do you have specific form fields that – if selected – should occupy more than one place when booked? The cevento/booking_places filter can be used to determine the number of spots a booking should occupy:

add_filter('cevento/booking_places', function ($spots, $fieldBag, $event) {
    return 1;
}, 10, 3);

Form Validation

Form validation hooks are always called with an instance of Cevento\Form\FieldBag. This instance can be used to access individual fields and their values as well as trigger validation errors.

getField('Name');

    // Get field value
    $nameValue = $nameField->getValue();

    // Trigger a dynamic validation error for a specific field
    if (strlen($nameValue) addError('The name must be at least 3 characters long.');
    }

    // Add a global error displayed above the form
    $fieldBag->addGlobalError('Any global error message can be displayed here.');
}, 10, 2);

add_action('cevento/validate/form=1', function ($fieldBag, $event) {
    // Specific validation rules for the form with ID 1 can be added here
});

Form Fields

The following filters can be used to customize form fields. This allows you to dynamically change custom field settings right before the form is rendered:

add_filter('cevento/prepare_field/field_80799639', 'CallbackHandler', 10, 1);
add_filter('cevento/prepare_field', function ($fieldConfig) {
    return $fieldConfig;
}, 10, 1);

Event Post Conversion

When converting an event into a post, only the content and title are transferred by default. The following hooks can be used to dynamically adjust categories or the content of the resulting post:

add_filter('cevento/event_to_post_terms', function ($terms, $evt) {
    return $terms; // Array of post term IDs
});

add_filter('cevento/event_to_post_content', function ($content, $evt) {
    return $content; // Any HTML string, by default the event's HTML content
});