Skip to main content

benecaster_feed_url_output

Filter Free

Filters the full rendered HTML output of the [benecaster_feed_url] shortcode. Returns an empty string when the current user is not a subscriber — the filter fires in that case too, making it possible to inject a subscribe prompt or call to action for non-subscribers.

For a subscriber, $html is in one of three states:

  • Recovered — the full working URL, an enabled Copy button, and a data-feed-url attribute on the wrapper (class benecaster-feed-url--recovered).
  • Not recoverable — the first few characters only, with Copy disabled.
  • Inactive — the show’s feed has gone dark, so there is a notice and no URL.

A callback that rewrites the output must handle all three, and must keep data-feed-url if it keeps the Copy button, because the front-end script reads it. The recovered state contains a working feed URL, so never log or cache $html.

Parameters

Name Type Default Description
$html string — Full rendered shortcode output; empty string if the current user is not a subscriber
$show_id int — ID of the show
$atts array — Resolved shortcode attributes

Returns: string

Examples

Inject subscribe link for non-subscribers

add_filter( 'benecaster_feed_url_output', function( $html, $show_id, $atts ) {
    // Show a subscribe prompt for non-subscribers (empty output).
    if ( '' === $html ) {
        $subscribe_url = get_post_meta( $show_id, '_benecaster_subscribe_url', true );
        return '<p>Subscribe to access your personal RSS feed. <a href="' . esc_url( $subscribe_url ) . '">Subscribe →</a></p>';
    }
    return $html;
}, 10, 3 );

Show simple fallback message when not subscribed

add_filter( 'benecaster_feed_url_output', function ( string $html, int $show_id, array $atts ): string {
    if ( '' === $html ) {
        return '<p>Subscribe to get your private feed URL.</p>';
    }
    return $html;
}, 10, 3 );

Affects

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