Skip to main content

Change the text of the subscribe button

Premium Intermediate

[benecaster_subscribe] on a show using Benecaster’s built-in membership labels each tier’s button Subscribe {billing period} — {price}, or Join free. The no-code way to change the middle is the billing-period label in Memberships → Tiers → Prices; for anything else, filter it.

The part that is easy to miss: a tier with several billing periods has one label per period, all worked out before the page loads, and the button swaps between them as the subscriber picks. So the callback must answer for every $price, not only the default one, or the button goes back to the default wording on the first click.

Return plain text: it is escaped, so markup prints literally. Translate your own strings in your own text domain; Benecaster’s default is already translated when it reaches you. The filter does not run on a show using MemberPress, WooCommerce Subscriptions, Paid Memberships Pro or Restrict Content Pro, where the button links to the plugin’s signup page; use translation or benecaster_subscribe_output there.

Code

<?php
add_filter( 'benecaster_subscribe_button_label', function ( string $label, ?array $price, int $show_id, string $tier_slug ): string {
    if ( null === $price ) {
        return __( 'Follow for free', 'my-theme' ); // Free tiers have no price.
    }
    if ( 'patron' !== $tier_slug ) {
        return $label;
    }
    $period = 'year' === $price['interval_unit']
        ? __( 'Become a Patron for the year', 'my-theme' )
        : __( 'Become a Patron', 'my-theme' );
    return sprintf( '%1$s — $%2$s', $period, number_format_i18n( $price['amount_cents'] / 100, 2 ) );
}, 10, 4 );

View on GitHub →

Hooks Used

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