Skip to main content

benecaster_account_sections

Action Free Since v1.0.0

Fires at the end of the [benecaster_account] shortcode output, after all core subscriber account sections — subscriptions, feed URL, QR code, and podcast app deep links — have rendered. Hook here to output additional HTML sections on the subscriber-facing account page.

Output is echoed directly from this action — there is no return value. The hook fires only when a logged-in subscriber is viewing their own account page through the front-end shortcode; it does not fire in the WordPress admin. On multi-show setups, this hook fires once per show card.

Parameters

Name Type Default Description
$show_id int ID of the show
$user_id int WordPress user ID of the logged-in subscriber

Examples

Output Discord connection section

add_action( 'benecaster_account_sections', function ( int $show_id, int $user_id ): void {
    if ( ! benecaster_addon_is_active( 'community-integrations' ) ) {
        return;
    }

    $discord_username = get_user_meta( $user_id, '_my_addon_discord_username', true );
    $verify_url       = esc_url( add_query_arg( [
        'action'  => 'discord-verify',
        'user_id' => $user_id,
        'nonce'   => wp_create_nonce( 'discord-verify-' . $user_id ),
    ], home_url() ) );

    echo '<section class="benecaster-account-section benecaster-discord-section">';
    echo '<h3>' . esc_html__( 'Discord Access', 'my-addon' ) . '</h3>';

    if ( $discord_username ) {
        echo '<p>' . sprintf(
            esc_html__( 'Connected as %s', 'my-addon' ),
            '<strong>' . esc_html( $discord_username ) . '</strong>'
        ) . '</p>';
    } else {
        echo '<p>' . esc_html__( 'Connect your Discord account to access the subscriber channel.', 'my-addon' ) . '</p>';
        echo '<a href="' . $verify_url . '" class="button">' . esc_html__( 'Connect Discord', 'my-addon' ) . '</a>';
    }

    echo '</section>';
}, 10, 2 );

Notes

Output is echoed directly — there is no return value. Use WordPress escaping functions (esc_html(), wp_kses_post(), etc.) in your callback.

Guard with benecaster_addon_is_active() and only output a section when your add-on's feature is configured for this show and user. Empty sections with no visible content add visual noise.

Fires only for the account owner. Benecaster verifies the logged-in user matches the subscriber record before rendering the account page and firing this action. You do not need to re-verify identity in your callback. This is a Free hook — it fires regardless of license status.

Affects

  • Subscriber Account Page
  • Subscriber Account Block (Blocks & Widgets)
  • Subscriber Account Widget — Elementor (Blocks & Widgets)