English (United Kingdom)

apply_filters( 'vikbooking_load_paxdatafields_drivers', array $return )

Fired during the plugin installation, it's necessary to define the driver paths to let VikBooking recognize them as check-in data collection drivers. Your driver(s) will then be available for selection in the Configuration settings.


Description

This hook is needed to create a new native Wordpress plugin that will be used by VikBooking to extend its check-in data collection framework. This is the back-end guests registration process, useful to comply with local authorities in your country of residence.


Parameters

$return

Function where you'll return the file paths for the callback of the filter 'vikbooking_load_paxdatafields_drivers'

Example

The example below explains how to define one custom data collection driver for the back-end guests registration functions. This driver will need to be selected afterwards from the apposite Configuration setting in VikBooking in order to be activated.

<?php
/*
Plugin Name:  VboCustomCheckinDriver
Plugin URI:   https://vikwp.com/plugin/vikbooking
Description:  Custom check-in driver for guests data collection in VikBooking.
Version:      1.0.0
Author:       E4J s.r.l.
Author URI:   https://vikwp.com
License:      GPL2
License URI:  https://www.gnu.org/licenses/gpl-2.0.html
Text Domain:  vbocustomcheckindriver
*/

// no direct access
defined('ABSPATH') or die('No script kiddies please!');

// register callback for filter "vikbooking_load_paxdatafields_drivers"
add_filter('vikbooking_load_paxdatafields_drivers', function($return)
{
    if (!$return)
    {
        $return = [];
    }

    /**
     * Since multiple plugins could add their own custom drivers, it is
     * necessary to always merge the paths to the driver files of this
     * plugin to any previous widget that may have already been injected.
     * Simply define an array of absolute paths to the PHP files that declare
     * the needed class by VikBooking to load a custom check-in driver.
     * 
     * In this example, we are telling VikBooking to load one custom check-in driver.
     */
    return array_merge($return, [
        // WP_PLUGIN_DIR          = absolute server path to plugin's directory
        // vbocustomcheckindriver = the name of this custom plugin
        // drivers                = a private/internal folder of this custom plugin
        // my_country.php         = the class file that declares the driver
        WP_PLUGIN_DIR . '/vbocustomcheckindriver/drivers/my_country.php',
    ]);
});

// register action to manipulate the pre-checkin pax registration fields
add_action('vikbooking_display_precheckin_pax_fields', function(&$precheckin_pax_fields) {
    // interested in customizing the front-end data collection fields for pre check-in?
    // refer to the apposite section to see how to properly implement this hook in the same custom plugin

    return;
}, 10, 3);

// make sure to load (require) the PHP Class of the custom driver "mycountry"
add_action('plugins_loaded', function()
{
    require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'drivers' . DIRECTORY_SEPARATOR . 'my_country.php';
});

One the plugin is installed and activated on your WordPress website, you will be able to see the custom driver in the apposite Configuration setting in Vik Booking.

Last Update: 2023-06-13
Helpful?