Skip to main content

benecaster_token_url

Filter Premium

Filters the full RSS feed URL shown to subscribers. Use to implement custom URL structures or add tracking parameters.

This filter fires in exactly one place — benecaster_get_feed_url(). Anything that builds a feed URL goes through that function, so your callback sees every one — a hand-assembled URL elsewhere in your own code silently opts out of your own filter.

Parameters

Name Type Default Description
$url string Full RSS feed URL for the subscriber
$token string The subscriber's plaintext token
$show_id int ID of the show
$user_id int WordPress user ID, or 0 when the caller did not supply one — it is the optional third argument of `benecaster_get_feed_url()`. Context only; nothing is looked up from it.

Returns: string

Example

add_filter( 'benecaster_token_url', function ( $url, $token, $show_id, $user_id ) {
    // Route token URLs through a short-link vanity domain.
    return str_replace( site_url(), 'https://feeds.mypodcast.com', $url );
}, 10, 4 );

Notes

$user_id can legitimately be 0. It is the optional third argument of benecaster_get_feed_url(), so any caller that does not have a user in scope passes nothing and your callback receives zero. **A callback that indexes user meta by $user_id without a guard will misbehave on that path** — and it is not an error path, so nothing will tell you.

Guard it explicitly:

```php add_filter( 'benecaster_token_url', function ( $url, $token, $show_id, $user_id ) { if ( 0 === $user_id ) { return $url; // No subscriber in scope — nothing to personalise. }

return my_addon_personalise( $url, $user_id ); }, 10, 4 ); ```

The token you receive is the plaintext one. Do not log it, and do not include it in anything a third party can read — it is the credential that serves that subscriber's private feed.

Need this built rather than just documented? See our services →