benecaster_access_gate_passes
Whether the visitor gets the gated branch of [benecaster_access_gate]. Fires before either branch renders, for conditions the attributes cannot express — an add-on’s own notion of a purchase, or an OR across several buy-ups. Whichever branch the returned value selects is still the only one that runs.
Fires for every access gate on the site, so a callback must scope itself by $show_id and $selector and return $passes untouched for gates it doesn’t mean to change.
Fires on every install, with no license check — website gating isn’t license-gated.
Website only. Does not fire when the RSS feed resolves a gate — feeds are compiled and cached per feed, not per visitor, and a per-visitor answer written into that cache would hand one buyer’s result to everyone on the same feed. A condition added through this filter opens the gate on the website only.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$passes |
bool |
— | Whether the visitor holds what the gate's selector names. |
$show_id |
int |
— | ID of the show the gate resolved to, or 0 when none could be resolved. |
$selector |
array |
— | The parsed selector — `kind` (`buyup`, `grant` or `any`), `slug` (string, empty for `any`) and `id` (int, the buy-up's row ID when the gate used `id`, otherwise 0). |
$user_id |
int |
— | The visitor's user ID, or 0 when logged out. |
Returns:
bool
Example
add_filter(
'benecaster_access_gate_passes',
function ( bool $passes, int $show_id, array $selector, int $user_id ): bool {
// Already in, or not the gate this snippet is about.
if ( $passes || 'buyup' !== $selector['kind'] || 'transcripts' !== $selector['slug'] ) {
return $passes;
}
// Also let holders of the "Bonus Bundle" buy-up see the transcripts.
// Its row ID in benecaster_buyups:
$bonus_bundle_buyup_id = 14;
return benecaster_user_has_buyup( $user_id, $bonus_bundle_buyup_id, $show_id );
},
10,
4
);
Notes
A gate written with both buyup and grant arrives here with $passes false and an empty buy-up selector.
Need this built rather than just documented? See our services →