English (United Kingdom)

apply_filters_ref_array( 'vikappointments_build_head_csv', bool $status, array &$head, mixed $handler )

Fires while constructing the head of the CSV table.


Description

Trigger hook to allow the plugins to manipulate the heading row of the CSV file. Here it is possible to attach new columns, detach existing columns and reorder them.

Notice that the same changes must be applied to the body of the CSV, otherwise the columns might result shifted.


Parameters

$status

(bool)  True on success, false on failure.

&$head

(array)  An array of columns.

$handler

(VAPOrderExportDriverCsv)  The instance used to export the records.


Example

/**
 * Trigger event to allow the plugins to manipulate the heading
 * row of the CSV file. Here it is possible to attach new columns,
 * detach existing columns and reorder them. Notice that the same
 * changes must be applied to the body of the CSV, otherwise the
 * columns might result shifted.
 *
 * @param  boolean  $status   True on success, false on failure.
 * @param  mixed    &$head    The CSV head array.
 * @param  mixed    $handler  The current handler instance.
 */
add_filter('vikappointments_build_head_csv', function($status, &$head, $handler)
{
    // include the user ID as a new column
    $head['id_user'] = __('User ID', 'my-custom-plugin');

    // get rid of order key column
    unset($head['sid']);

    return $status;
}, 10, 3);

Changelog

Version Description
1.2 Introduced.
Last Update: 2021-11-17
Helpful?