Add a “manage your plan” link for members who already have one
When a logged-in member who already pays for a plan visits your subscription page, [benecaster_subscribe] shows them which plan they’re on instead of selling it to them again. Benecaster doesn’t put a link in that panel, because it can’t know where your account page is: it’s wherever you placed [benecaster_account]. This adds one.
- Add it for
paidmembers only. Members on a free plan and people following the show
still see every paid tier under the panel, because this page is how they upgrade. A second link next to that offer competes with it. - Branch on
state, never on a token type. An add-on’s own listener type arrives
already resolved topaid,freeorfollower. - Returning an empty string removes the panel. For a paid member that leaves nothing
at all, since they’re shown no tier cards.
Replace the page path with wherever your [benecaster_account] page lives.
Code
<?php
add_filter(
'benecaster_subscribe_current_membership',
function ( string $html, array $membership, int $show_id ): string {
// Only the people who actually have something to manage.
if ( 'paid' !== $membership['state'] ) {
return $html;
}
$account = get_page_by_path( 'my-account' ); // your [benecaster_account] page
if ( ! $account ) {
return $html;
}
return $html . sprintf(
'<p><a href="%s">%s</a></p>',
esc_url( get_permalink( $account ) ),
esc_html__( 'Manage your plan', 'my-plugin' )
);
},
10,
3
);
Hooks Used
Need this built rather than just documented? See our services →