Skip to main content

Describe each tier on a membership-plugin show’s subscribe cards

Premium Intermediate

On a show using MemberPress, WooCommerce Subscriptions, Paid Memberships Pro or Restrict Content Pro, [benecaster_subscribe] prints each tier’s name, the plugin’s price and a Subscribe button to the plugin’s signup page — but no description, because Benecaster’s tier mapping holds none. This example pulls one from the membership plugin’s own level, so the description is written in one place: here, each MemberPress membership’s excerpt.

Do not print a price or a button in this hook. Benecaster prints both, so yours would be a second one.

Two levels mapped to one tier render two cards with the same $slug. The hook has no level argument, so this example describes both with the first level’s text. Map one level per tier if each needs its own description.

The benecaster-subscribe__description class picks up the description styling Benecaster’s subscribe stylesheet already has. It is one of the card classes listed on the subscribe shortcode’s page.

A show on Benecaster’s built-in membership never fires this hook; its tier descriptions are edited under Memberships → Tiers.

Code

<?php
// MemberPress: show each membership's excerpt under its card.
add_action( 'benecaster_subscribe_tier_content', function ( string $slug, int $show_id ): void {
    global $wpdb;
    $level_ids = $wpdb->get_col( $wpdb->prepare(
        "SELECT external_tier_id FROM {$wpdb->prefix}benecaster_tier_map
         WHERE show_id = %d AND internal_tier_slug = %s AND plugin_slug = 'memberpress'",
        $show_id,
        $slug
    ) );
    $level_id = (int) ( $level_ids[0] ?? 0 );
    $excerpt  = $level_id ? get_the_excerpt( $level_id ) : '';
    if ( '' !== $excerpt ) {
        echo '<p class="benecaster-subscribe__description">' . esc_html( $excerpt ) . '</p>';
    }
}, 10, 2 );

View on GitHub →

Hooks Used

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