Show locked search results, or replace their card
Turn the AI Search box into a reason to subscribe: show members-only episodes a visitor cannot open as locked cards in their ranked place, with an upgrade link, and replace that card with your own if you like.
result_visibility is a benecaster_ai_search attribute, per box. hidden (the default) leaves out an episode the visitor cannot open; locked keeps it in its ranked place as a lock card. Ranking is the same in both: every episode is ranked, and only the display differs. A locked result is title only: its date, description, excerpt and any transcript text are never sent, even when its transcript ranked it first. Two boxes on one page can use different modes.
The card is a padlock (.benecaster-ai-search__lock, role="img", labeled Locked), the title linked to the episode’s page (.benecaster-ai-search__link), a tier line (.benecaster-ai-search__tier) and the upgrade link (.benecaster-ai-search__cta), inside .benecaster-ai-search__locked.
- Tier line: Available to {tier} subscribers when benecaster_get_episode_access_tiers() lists exactly one paid tier (a
publicentry, a windowed release’s later date, is not counted); otherwise Available to subscribers (several tiers, a buy-up, or none: that list leaves out standalone grants, and empty does not mean public). - Upgrade link:
locked_cta_urlif set, else benecaster_get_signup_url() for the show and the visitor searching; labeledlocked_cta_label, else Subscribe to access.
benecaster_ai_search_locked_result( string $card, int $episode_id, int $user_id, string $cta_html ): string runs per locked result. Return your own markup to replace the card; $cta_html is the default upgrade link, to reuse. Never add the episode’s description, notes or transcript: the visitor cannot open it. The result is passed through wp_kses() (what a post may contain, plus svg and path) before it is sent, because the box inserts it as HTML.
[benecaster_ai_search result_visibility="locked" locked_cta_url="/join/" locked_cta_label="Unlock the full archive"]
Code
<?php
// A members-only card that names the price.
add_filter( 'benecaster_ai_search_locked_result', function ( string $card, int $episode_id, int $user_id, string $cta_html ): string {
return '<div class="benecaster-ai-search__locked my-locked">'
. '<strong>' . esc_html( get_the_title( $episode_id ) ) . '</strong> '
. esc_html__( 'is for members, from $5 a month.', 'my-theme' ) . ' ' . $cta_html
. '</div>';
}, 10, 4 );
Hooks Used
Need this built rather than just documented? See our services →