RestrictContentBridge
\Benecaster\Bridge\Bridges\RestrictContentBridge
The built-in bridge for Restrict Content Pro. Slug: restrict-content. Detection: defined('RCP_PLUGIN_VERSION'). Minimum version: RCP 3.0. Routes subscription lifecycle events through rcp_transition_membership_status status transitions and rcp_membership_post_renew. Both on_subscription_changed() and on_payment_failed() are documented no-ops.
Implements BridgeInterface and BridgeWritable, and uses ManualMembershipUnsupportedTrait — create_manual_membership() always throws. The full method contract is documented once on BridgeInterface and BridgeWritable; the table below covers only what this implementation does differently.
Constructor Dependencies
| Type | Description |
|---|---|
TierMapRepository |
Resolves RCP subscription level IDs to Benecaster internal tier slugs, scoped per show. |
Methods
| Method | Visibility | Since | Description |
|---|---|---|---|
get_plugin_slug(): string |
Public | — | Returns 'restrict-content'. |
get_user_tier( int $user_id, int $show_id ): ?string |
Public | — | Resolves the user's RCP customer record, then iterates its active memberships and returns the tier slug of the first whose subscription level is mapped to $show_id. Returns null if there is no customer record or rcp_get_customer_from_user_id() is unavailable. |
get_all_user_tiers( int $user_id, int $show_id ): array |
Public | — | Same iteration as get_user_tier(), but collects every matching tier slug — a customer with two active RCP memberships mapped to the same show gets both. |
is_user_active( int $user_id, int $show_id ): bool |
Public | — | true when get_user_tier() returns non-null. |
get_all_tiers( int $show_id ): array |
Public | — | Returns every RCP subscription level from rcp_get_subscription_levels() as a candidate tier ({id, name, price}). $show_id is accepted for interface compatibility but unused — RCP levels are site-wide. Returns [] when the function is unavailable. |
on_subscription_activated( callable $callback ): void |
Public | — | Registers on rcp_transition_membership_status, filtered to new_status === 'active'. source is 'new' when the previous status was 'pending' (a brand-new checkout), 'resubscribe' otherwise (admin grant, reactivation after cancellation or expiry). |
on_subscription_cancelled( callable $callback ): void |
Public | — | Registers on rcp_transition_membership_status, filtered to new_status in ['cancelled', 'expired'], reporting SubscriptionEndReason::CANCELLED or ::EXPIRED accordingly. |
on_subscription_changed( callable $callback ): void |
Public | — | No-op. An RCP level change cancels the old membership before the new one is active. Benecaster holds that cancellation to the end of the request and drops it when an active membership on the same show replaced it, so the new membership's activation moves the tier on the still-active token and fires benecaster_subscription_tier_moved; the token is never revoked in between. |
on_subscription_renewed( callable $callback ): void |
Public | — | Registers on rcp_membership_post_renew, fired after RCP extends a membership's expiry following a successful recurring payment. |
on_payment_failed( callable $callback ): void |
Public | — | No-op. RCP has no payment-failure hook that is universal across gateways — a failed recurring charge eventually surfaces as an 'expired' status transition, caught by on_subscription_cancelled() instead. Fine-grained failure tracking needs the active gateway's own rcp_gateway_* hooks. |
on_tier_saved( callable $callback ): void |
Public | — | Registers on both rcp_add_subscription_level and rcp_edit_subscription_level, and calls $callback with the level re-fetched via rcp_get_subscription_level() as {id, name, price}. |
register_admin_hooks(): void |
Public | — | Not part of BridgeInterface — called by Plugin.php at boot for any bridge that defines it. Renders a per-show tier dropdown on the RCP subscription level edit screen and persists the selection when the level is added or saved. |
can_import(): bool |
Public | — | true when rcp_add_membership(), rcp_get_customer_by_user_id(), rcp_add_customer() and rcp_get_subscription_level() all exist. |
create_member( string $email, int $user_id, int $tier_id, array $meta = [] ): bool |
Public | — | Creates an RCP customer record for the user if one doesn't exist, then grants the level via rcp_add_membership() with status 'active', gateway 'manual', and an expiration date from $meta['expires_at'] (or 'none'). No payment record is created. |
supports_tier( int $tier_id ): bool |
Public | — | true when $tier_id resolves to a real RCP subscription level via rcp_get_subscription_level(). |
create_manual_membership( int $user_id, int $show_id, string $tier_slug, ?string $expiry_at ): array |
Public | — | Inherited from ManualMembershipUnsupportedTrait — always throws BadMethodCallException. |