Skip to main content

Customize the Upgrade Prompt for a Specific Show

Premium Beginner

Change the wording of the upgrade prompt a logged-in subscriber sees when they land on an episode above their tier, or add a link to it, using benecaster_upgrade_prompt_html. The filter receives the show ID, so a site running several shows can vary the prompt per show rather than site-wide.

For a full rebuild rather than a copy change, override the upgrade-prompt template from a child theme instead — the episode, the show, the tier the episode requires and the tier the subscriber is actually on are all available inside the template. See Template Overrides for where the file goes.

Code

<?php
add_filter(
    'benecaster_upgrade_prompt_html',
    function ( string $html, int $episode_id, int $show_id, string $required_tier, string $user_tier ): string {
        if ( $show_id !== 42 ) {
            return $html;
        }
        return sprintf(
            '<p class="my-upgrade">This episode is for %s subscribers. <a href="/subscribe/">Upgrade your plan →</a></p>',
            esc_html( $required_tier )
        );
    },
    10,
    5
);

View on GitHub →

Hooks Used

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