benecaster_before_export
Fires at the start of XLSX file generation for the “Your Data” export, before any sheet row filters run. The sheet list is final and row data has been collected at this point.
The $sheets array reflects only the sheets the user selected for this export run, not all registered sheets. This action fires on the generation pass only — not on the UI render pass that builds the sheet checkboxes. Use it for logging, pre-generating expensive data, or performing upfront capability checks.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$sheets |
array |
— | The sheets selected for this export |
$context |
array |
— | Export context: {show_id: int|null, date_start: string, date_end: string} |
Examples
Log export start with context
add_action( 'benecaster_before_export', function ( array $sheets, array $context ): void {
$sheet_ids = array_column( $sheets, 'id' );
error_log( sprintf(
'[Benecaster] Export started — show=%s sheets=%s range=%s to %s',
$context['show_id'] ?? 'all',
implode( ',', $sheet_ids ),
$context['date_start'],
$context['date_end']
) );
}, 10, 2 );
Need this built rather than just documented? See our services →