Skip to main content

benecaster_show_episode_download

Filter Free

Controls whether the episode page shows its “Download episode” link to the current visitor. The link appears beneath the player when the show’s Show a download link on episode pages setting (Show Settings → Feeds, off by default) is on and the visitor can play the episode. $show_download starts at exactly that: the setting AND the visitor’s access. The filter always fires, so a callback sees the default either way.

The filter can only hide the link. Benecaster combines your return value with the starting value, so returning true for a visitor who cannot play the episode, or on a show where the setting is off, shows nothing. This differs from benecaster_show_episode_player, which a preview add-on uses to open the player: a download link opened to a locked visitor would hand them the full file, and a preview clip that opens the player does not open the download link.

The link points at the same audio URL the player uses (after benecaster_episode_audio_url), which sits at your podcast host. It protects nothing the player’s audio does not: anyone who can play the episode can reach the file, and a copied URL works for whoever holds it.

The link renders in the episode/download template part, which a theme can override (see Template Overrides). Benecaster’s single.php decides whether to include the part and the part does not re-check access, so a theme that overrides single.php must call \Benecaster\Episode\EpisodePageLinkGate::shows_download() itself before including it.

Offer episode downloads to paying subscribers only

Free Beginner

With Show a download link on episode pages switched on, the “Download episode” link shows to everyone who can play the episode, including every visitor on a public episode. This keeps it for subscribers.

The filter can only hide the link. Returning true for a visitor who can’t play the episode, or on a show where the setting is off, shows nothing, so a trial-access callback that unlocks the player does not extend downloads to trial users. The link is the host’s audio URL, the same one the player uses.

<?php
add_filter( 'benecaster_show_episode_download', function ( bool $show, int $episode_id, ?int $user_id, ?string $user_tier ): bool {
    return $show && null !== $user_tier;
}, 10, 4 );

View on GitHub →

Parameters

Name Type Default Description
$show_download bool Whether Benecaster would show the link (setting on and the visitor can play the episode)
$episode_id int ID of the episode
$user_id int|null WordPress user ID; null if not logged in
$user_tier string|null Current tier slug; null if user has no active tier

Returns: bool

Example

// Offer downloads to paying subscribers only, not to visitors of public episodes.
add_filter( 'benecaster_show_episode_download', function ( bool $show, int $episode_id, ?int $user_id, ?string $user_tier ): bool {
    return $show && null !== $user_tier;
}, 10, 4 );

Notes

Free. The filter fires in the free product's episode template, beside its free siblings.

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