Add a Custom Section at the End of a Subscription Card on the Subscriber Account Page
Use benecaster_after_account_email_preferences to append a section after all built-in content on a subscription card. Email preferences is the last built-in section, after the QR code. The action fires with ( int $show_id, int $user_id ). To insert before a built-in section instead, use the corresponding benecaster_before_* hook, such as benecaster_before_account_subscription before the subscription summary.
Most account hooks pass both $show_id and $user_id, but not all. The four that wrap sections rendered once for the person rather than once per subscription (benecaster_before_account_profile, benecaster_after_account_profile, benecaster_before_account_avatar and benecaster_after_account_avatar) pass $user_id alone, because no show is in scope. A callback copied from a per-card hook and registered with two accepted arguments receives null as its second.
Code
<?php
add_action(
'benecaster_after_account_email_preferences',
function ( int $show_id, int $user_id ): void {
$history_url = add_query_arg(
[ 'show' => $show_id, 'subscriber' => $user_id ],
home_url( '/episode-history/' )
);
printf(
'<div class="my-account-history"><h3>%s</h3><a href="%s">%s</a></div>',
esc_html__( 'Your listening history', 'my-plugin' ),
esc_url( $history_url ),
esc_html__( 'View episodes you\'ve accessed →', 'my-plugin' )
);
},
10,
2
);
Hooks Used
Need this built rather than just documented? See our services →