benecaster_get_feed_url()
benecaster_get_feed_url( string $token, int $show_id, int $user_id = 0 ): string
Builds one subscriber’s private feed URL for one show, from a token you already hold. The URL carries that token, so it is personal to them — it belongs in their email and on their own account screen, and nowhere a different visitor could read it.
Use this rather than assembling the URL yourself. The format has changed before and this function is what absorbs the next change. It is also the single place the benecaster_token_url filter is applied, so a hand-built URL silently opts out of any add-on that rewrites feed URLs to pretty permalinks.
Parameters
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
$token |
string |
— | Yes | The plaintext feed token, as handed to you at generation or reset. This function does not look one up. |
$show_id |
int |
— | Yes | Show post ID the token belongs to. |
$user_id |
int |
0 |
No | Subscriber user ID. Passed to the benecaster_token_url filter as context only — nothing is resolved from it. |
Return Value
Type:
string
The absolute feed URL, or an empty string when $token is empty. Never null.
Example
// The plaintext token exists in readable form exactly once: here.
add_action(
'benecaster_token_generated',
function ( int $token_id, int $user_id, int $show_id, string $tier_slug, string $token ) {
$feed_url = benecaster_get_feed_url( $token, $show_id, $user_id );
// Store it, send it, or hand it to your own onboarding flow now —
// it cannot be rebuilt from $user_id later.
update_user_meta( $user_id, 'my_addon_last_feed_url', $feed_url );
},
10,
5
);
Hooks Fired
Notes
This function takes a token. It cannot find one for you. To get a subscriber's URL from a user ID and show ID, call TokenManager::feed_url_for( $user_id, $show_id ), which recovers the token from its encrypted copy and calls this function for you. It returns null when the token can't be recovered (a token created before recoverable copies were kept, a changed encryption key, or a server without libsodium). In that case the account screen shows a shortened ?token=abc12345… built from the stored prefix.
If you need the URL with certainty, capture the plaintext token when it is issued, from benecaster_token_generated or a reset response. Recovery later is usually possible, but not guaranteed.
If you omit $user_id, the benecaster_token_url filter receives 0 — not null, and not a resolved ID. Callbacks on that filter must guard for it; see benecaster_token_url.
Need this built rather than just documented? See our services →