Redirect feed URLs to pretty permalink format
For core’s own pretty form you need no code. Tick Benecaster → Settings → Permalinks → Private feed URLs → Use pretty feed URLs and every subscriber URL becomes /podcast/{feed-slug}/feed/{token}/, with the rewrite rules registered for you, kept registered even after the switch is turned back off, and a renamed feed slug still resolving correctly by the token. Use this recipe only for a different shape than that.
Applied wherever Benecaster builds a subscriber’s private feed URL from their plaintext token — the welcome email and its deep links, the subscriber’s self-service reset-token response, the admin POST /subscribers/{id}/reset-token response (the one-time URL the subscriber panel shows after a reset), and follower signup. It does not apply to the masked display URLs (account page, [benecaster_feed_url], the admin subscriber panel) — those are never working URLs and follow the core switch only.
Build the URL from $token and $show_id, never by editing $url. If the built-in switch above is on, $url arrives already in the pretty form, so a str_replace( '?token=', … ) against it finds nothing to replace and silently does nothing — write your filter to construct the URL fresh, as the example does.
Your custom shape needs its own rewrite rule, routed to Benecaster’s feed controller by the benecaster_feed query vars — re-save Settings → Permalinks once after adding it.
Code
<?php
// Serve subscriber feeds at /listen/{token}/ instead.
// Add this to functions.php or a site-specific plugin.
add_filter(
'benecaster_token_url',
function ( string $url, string $token, int $show_id, int $user_id ): string {
return home_url( '/listen/' . rawurlencode( $token ) . '/' );
},
10,
4
);
// A custom shape needs its own rewrite rule, routed to Benecaster's feed
// controller by the benecaster_feed query vars. With no show slug in the
// URL, the feed takes the show from the token. Re-save Settings ->
// Permalinks once after adding it.
add_action( 'init', function (): void {
add_rewrite_rule(
'^listen/([^/]+)/?$',
'index.php?benecaster_feed=1&benecaster_feed_token=$matches[1]',
'top'
);
} );
Hooks Used
Need this built rather than just documented? See our services →