Append custom columns or short-circuit the write for download log rows
benecaster_download_log_entry runs right before $wpdb->insert(). Use it to add columns from a schema migration your add-on shipped (e.g. a campaign ID resolved from the request), normalise an existing column, or skip the insert entirely. Return an empty array to skip the insert and suppress the paired benecaster_download_logged action.
Code
<?php
add_filter(
'benecaster_download_log_entry',
function ( array $data, int $episode_id, int $user_id ): array {
// Tag the row with a request-scoped campaign attribute.
$campaign = isset( $_GET['utm_campaign'] ) ? sanitize_key( wp_unslash( $_GET['utm_campaign'] ) ) : '';
if ( '' !== $campaign ) {
$data['campaign'] = $campaign;
}
return $data;
},
10,
3
);