Skip to main content

benecaster_magic_link_validated

Action Free

An episode magic link is a signed link to one episode for one subscriber, made with benecaster_get_episode_access_url(). The Email Editor puts one in its new-episode emails, and you can put one in your own. This action fires when someone opens such a link and it is accepted: the signature checks out, the link has not expired, the episode is published on the link’s show, and the subscriber can still play it today.

By the time it fires, a 30-day cookie for that one episode has been set and the visitor is about to land on the episode page. Nobody is logged in. The cookie opens that episode for a logged-out visitor and nothing else; account pages still need a real login.

It fires on the click only. Later visits that the cookie opens do not fire it, and neither does a refused link (a bad signature, an expired link, an unpublished episode, or a subscriber who no longer has access): the visitor lands on the episode’s ordinary locked page with ?benecaster_episode_link_refused=1 and is never told why. Use it for click logging or analytics.

Parameters

Name Type Default Description
$user_id int — WordPress user ID
$episode_id int — ID of the episode post
$show_id int — ID of the show

Examples

Log episode link clicks

add_action( 'benecaster_magic_link_validated', function ( int $user_id, int $episode_id, int $show_id ): void {
    my_analytics_track( 'episode_link_opened', [
        'user_id'    => $user_id,
        'episode_id' => $episode_id,
        'show_id'    => $show_id,
    ] );
}, 10, 3 );

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