Preview as Tier REST API
Three endpoints for activating, reading, and clearing the “Preview as Tier” admin feature. Preview mode lets an admin see the subscriber-facing front end exactly as a subscriber at a specific tier would see it — including episode access, locked states, player visibility, and episode archive. Preview is scoped to a show and tier and stored as a session cookie; it never affects what actual subscribers see.
All three endpoints require manage_options and a valid X-WP-Nonce header.
GET /benecaster/v1/tools/preview-tier
Returns the current preview state for this admin session.
Auth: manage_options + X-WP-Nonce
Response (active preview):
{
"active": true,
"show_id": 45,
"tier_slug": "basic"
}
Response (no active preview):
{
"active": false,
"show_id": null,
"tier_slug": null
}
POST /benecaster/v1/tools/preview-tier
Activates preview mode for a specific show and tier.
Auth: manage_options + X-WP-Nonce
Body:
{
"show_id": 45,
"tier_slug": "basic"
}
Response:
{
"active": true,
"show_id": 45,
"tier_slug": "basic"
}
Errors:
| Code | HTTP | Condition |
|---|---|---|
show_not_found |
404 | show_id does not exist |
invalid_tier |
400 | tier_slug does not exist on this show |
invalid_param |
400 | show_id or tier_slug missing |
How it works:
Activating preview sets a session cookie benecaster_preview_tier containing {"show_id": 45, "tier_slug": "basic"}. The PreviewTierManager class hooks benecaster_episode_is_accessible and benecaster_user_tier_for_show — when the cookie is present and the admin is viewing the show’s front end, both filters return values as if the current user holds a token at the preview tier. Existing subscribers are not affected; the preview only applies to the admin’s own browser session.
A preview mode banner is displayed to the previewing admin and is not visible to anyone else.
DELETE /benecaster/v1/tools/preview-tier
Clears the active preview. Removes the benecaster_preview_tier session cookie.
Auth: manage_options + X-WP-Nonce
Response:
{
"active": false
}
Calling this endpoint when no preview is active returns the same response — it is idempotent.
Preview is also cleared on logout. The session cookie is tied to the admin’s session; logging out clears it automatically regardless of whether this endpoint is called.
Filters
Preview mode works by hooking two filters. These filters fire during normal episode access evaluation — add-on code that filters benecaster_episode_is_accessible or benecaster_user_tier_for_show will interact with preview mode. If your add-on also hooks these filters, make sure it respects values already set by PreviewTierManager rather than overriding them unconditionally.
| Filter | How preview uses it |
|---|---|
benecaster_episode_is_accessible |
Returns preview-tier access decisions when preview cookie is present |
benecaster_user_tier_for_show |
Returns the preview tier slug instead of the user’s actual tier when preview cookie is present |