« All Handlers

onCSVOutput

The onCSVOutput handler is called when LiveWhale exports a CSV, allowing you to filter or customize it however you like. The example module below adds a new custom column to an exported CSV of event registrations.

Parameter Description
$data_type “event_registrations”, “users”, or “quickaccess”
$rows An array of every row of the CSV
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<?php
$_LW->REGISTERED_APPS['my_app']=[
'title'=>'My App',
'handlers'=>['onValidateUpload'],
];

class LiveWhaleApplicationMyApp {

public function onCSVOutput($data_type, $rows) { // formats CSV output
global $_LW;

if ($data_type=='event_registrations') { // if these are event RSVPs
foreach($rows as $key=>$val) {
if ($key===0) { // add custom column to the header row
$rows[$key][]='Appointment Time';
$custom_column_key=sizeof($rows[$key])-1;
}
else { // add custom value to each row, in that column
$custom_value = ''; // you could run a db query, load custom values, or make a calculation based on other column values
$rows[$key][$custom_column_key]=$custom_value; // add the value to this row
};
};
};

return $rows;
}

}
?>