benecaster_feed_after_render
Fires immediately after Benecaster finishes echoing the compiled feed XML to output, before the request exits. The XML has already been sent to the subscriber’s podcast app when this hook fires.
Use this hook for post-render logging, analytics side-effects, or measuring render time in combination with [benecaster_feed_before_render](/hooks/benecaster_feed_before_render/). The `$xml` parameter is a copy of what was sent — it is useful for inspecting feed size or content for observability purposes, but it is not a modifiable buffer. To modify feed XML before it is sent, use the [benecaster_feed_xml](/hooks/benecaster_feed_xml/) filter instead.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$show_id |
int |
— | ID of the show |
$tier_slug |
string |
— | Tier slug for this feed request |
$xml |
string |
— | The full RSS XML string that was output |
Examples
Log feed render size and elapsed time
// Store the start time in benecaster_feed_before_render.
add_action( 'benecaster_feed_before_render', function (
int $show_id,
string $tier_slug
) {
$GLOBALS['_benecaster_render_start'] = microtime( true );
}, 10, 2 );
// Log size and elapsed time after the feed is sent.
add_action( 'benecaster_feed_after_render', function (
int $show_id,
string $tier_slug,
string $xml
) {
$elapsed_ms = round( ( microtime( true ) - ( $GLOBALS['_benecaster_render_start'] ?? 0 ) ) * 1000 );
$size_kb = round( strlen( $xml ) / 1024, 1 );
error_log( sprintf(
'Benecaster feed rendered: show=%d tier=%s time=%dms size=%skb',
$show_id, $tier_slug, $elapsed_ms, $size_kb
) );
}, 10, 3 );
Notes
The XML has already been sent to the client when this hook fires — changes to $xml have no effect on the response. Use the benecaster_feed_xml filter if you need to modify feed XML before it is sent. Do not attempt to set or modify HTTP headers inside this callback — headers have already been flushed.