Skip to main content

Customize [benecaster_current_tier] output

Premium Beginner

The current-tier shortcode drops a subscriber’s tier name onto a page. That is deliberately plain, and often not quite what a podcaster wants — they would rather greet the person by name, mark them as a founding supporter, or say something entirely different to a visitor who is not signed in at all.

benecaster_current_tier_output is the last thing to touch that text before it reaches the page. Handle the logged-out case deliberately: for a guest, or anyone without active access, there is no tier and no user to work with, and a callback that assumes otherwise will fail on exactly the visitors a podcaster most wants to convert.

Code

<?php
add_filter(
    'benecaster_current_tier_output',
    function ( string $output, int $show_id, ?string $tier_slug, ?\WP_User $user, array $atts ): string {
        if ( null === $tier_slug || null === $user ) {
            return $output; // guest / no token — respect the shortcode's fallback
        }
        return sprintf(
            /* translators: 1: first name, 2: tier display name */
            __( 'Welcome back, %1$s — your current tier is %2$s.', 'my-addon' ),
            esc_html( $user->display_name ),
            esc_html( $output )
        );
    },
    10,
    5
);

View on GitHub →

Hooks Used

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