Send every subscribe link to one page
If your sign-up form lives on its own page rather than on the show’s page, tell Benecaster once. Two places ask where the subscribe page is: the subscriber account page, when it offers a member on the free plan a paid one, and [benecaster_qr_code type="signup"]. Both go through this filter, so a printed QR code and the in-app upgrade link always point at the same page. An add-on that needs the same answer calls benecaster_get_signup_url( $show_id, $user_id ) rather than applying the filter itself.
$user_idis0for a QR code. A code printed on a poster has no viewer. Treat0
as “no particular member” and only personalise the URL when there’s a real ID.- Fall back to the
$urlyou were given when you have no answer. Never return an empty
string or a guessed address. - One code can override it.
[benecaster_qr_code type="signup" signup_url="…"]points
that one code somewhere else, so a campaign landing page doesn’t need the filter. - Feed QR codes are unaffected. They always encode the subscriber’s own private feed.
Code
<?php
add_filter(
'benecaster_signup_url',
function ( string $url, int $show_id, int $user_id ): string {
$page = get_page_by_path( 'join' );
if ( ! $page ) {
return $url; // Always fall back: never return '' or a guess.
}
// $user_id is 0 for a public QR code. Only personalise when a
// member is actually in context.
if ( 0 !== $user_id ) {
return add_query_arg( 'upgrade', $user_id, get_permalink( $page ) );
}
return get_permalink( $page );
},
10,
3
);
Hooks Used
Need this built rather than just documented? See our services →