Skip to main content

benecaster_show_episode_player

Filter Free Since v1.0.0

Controls whether the audio/video player is rendered for the current user. The primary hook for add-ons that implement preview players or time-limited access.

Parameters

Name Type Default Description
$show_player bool Whether to show the player to the current user
$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

add_filter( 'benecaster_show_episode_player', function( $show_player, $episode_id, $user_id, $user_tier ) {
    // Show a 90-second preview player to logged-out visitors on public episodes.
    if ( ! $user_id ) {
        $is_public = get_post_meta( $episode_id, '_benecaster_public_preview', true );
        if ( $is_public ) {
            return true;
        }
    }
    return $show_player;
}, 10, 4 );