Stream every authenticated 302-proxy download event to an external webhook
benecaster_download_logged fires from DownloadLog::record() immediately after a row lands in benecaster_download_log. Use it to fan the event out to a webhook receiver, Slack channel, or real-time pipeline without touching the proxy code path. Pair with benecaster_download_log_entry (see tag-download-log-rows-with-extra-data) to append custom columns before insertion.
Code
<?php
add_action(
'benecaster_download_logged',
function ( int $episode_id, int $user_id, array $log_entry ): void {
wp_remote_post(
'https://example.com/webhooks/benecaster-downloads',
[
'timeout' => 5,
'blocking' => false,
'body' => wp_json_encode( [
'episode_id' => $episode_id,
'user_id' => $user_id,
'tier_slug' => $log_entry['tier_slug'] ?? null,
'requested_at' => gmdate( 'c' ),
] ),
]
);
},
10,
3
);