Skip to main content

benecaster_guest_manager_get_guest()

Episode Premium guest-manager
benecaster_guest_manager_get_guest( int $guest_id ): ?array

One guest by id, as they are now, for an add-on that keeps a guest’s id, such as Transcription’s speaker mapping or AI Search. It is the one supported way to read a guest: never read the benecaster_guest post or its meta directly. See Read one guest by id from another add-on.

Parameters

Name Type Default Required Description
guest_id int — Yes A benecaster_guest post id.

Return Value

Type: array|null

The guest, [ 'id' => int, 'name' => string, 'title' => string, 'organization' => string, 'website' => string, 'photo_url' => string, 'profile_url' => string, 'bio' => string, 'edit_url' => string, 'publications' => array ]: the keys of benecaster_guest_manager_get_episode_guests(), with the same meanings, plus photo_url, the guest's photo at thumbnail size or '' without one; bio, the guest's bio as plain text, or '' without one; edit_url, the guest's record on the Guests screen in Benecaster's admin; and publications, a list of { title, url, year, type, affiliate } in the podcaster's order ([] for none): url the plain address or '', never an Outlinks /go/ one; year four digits or ''; type book, article, paper or other; affiliate false when there is no link. null when the id is not a published guest (an unknown id, a trashed guest, a draft, another post type), and when Guest Manager is off on every show.

Example

$guest = function_exists( 'benecaster_guest_manager_get_guest' )
    ? benecaster_guest_manager_get_guest( $guest_id )
    : null;

echo esc_html( null !== $guest ? $guest['name'] : $stored_name );

Hooks Fired

Notes

Not gated by show. Guests are the site's, not a show's, so no show is asked about. When you draw the guest on an episode, check that episode's show yourself with benecaster_addon_is_active() ( 'benecaster-addon-guest-manager', $show_id ), as benecaster_guest_manager_get_episode_guests() does for you.

Store the name too. Keep the guest's id and their name at the time you store it, show this function's current name, and fall back to the stored name when it returns null or Guest Manager is off for the episode's show. A rename then reaches everything you draw, and a deleted guest leaves the name you saved.

bio is plain text: tags (and any script or style) stripped, HTML entities decoded, every run of spaces and line breaks made one space. It is meant for search and embedding, such as AI Search; for the formatted bio, use the guest's page or the [benecaster_guest] shortcode.

edit_url opens the guest on the first show where Guest Manager is on, because the Guests screen is drawn only for such a show. It is returned whoever is viewing: it is an admin address that WordPress refuses to anyone without access, so it tells a visitor nothing the id does not. Show the link only to someone who can open it (current_user_can( 'manage_options' )). It is '' only when Benecaster does not provide benecaster_get_admin_url(). Use it rather than building the address yourself, so the link keeps working if the admin's routes change.

Values are raw text, so escape them on output. The guest's private email is never included. It is defined on every request while Guest Manager is active. Guard calls with function_exists(), since Guest Manager may not be installed. Keys may be added in later versions; none will be removed or change meaning.

To read every guest a page at a time, use benecaster_guest_manager_get_guests(); for the episodes a guest appears in, use benecaster_guest_manager_get_guest_episodes().

Need this built rather than just documented? See our services →