benecaster_get_episode_publish_data()
benecaster_get_episode_publish_data( string $key, mixed $default = null ): mixed
Returns what a section your add-on put in the episode editor’s Ready to Publish? dialog sent under $key with set_publish_data( key, value ), for the episode save now running. It works on a first publish too, when your section has no episode ID to send its own request against.
It is readable for the whole save: from benecaster_episode_published, which fires before the episode’s other fields are written, through benecaster_availability_unlocked for a tier available at publish, which fires as the save ends. Only a save that publishes carries any.
Parameters
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
key |
string |
— | Yes | The key your section passed to set_publish_data(). |
default |
mixed |
null |
No | What to return when this save carried nothing under $key. |
Return Value
Type:
mixed
The value as the admin's browser sent it, or $default.
Example
add_action( 'benecaster_episode_published', function ( int $episode_id ): void {
$send = benecaster_get_episode_publish_data( 'my_addon_send' );
if ( null !== $send ) {
update_post_meta( $episode_id, '_my_addon_send', (bool) $send ? '1' : '0' );
}
} );
Notes
Benecaster keeps none of it. A tier that unlocks on a later date does so from WP-Cron, where this returns $default. Save the value yourself on benecaster_episode_published, which gives you the episode ID.
Values arrive as the browser sent them. Only keys are sanitized, so sanitize each value as you would any request input. $default also comes back for a publish from the block editor or WP-CLI, where the dialog never opened. See Send a pre-publish choice with the publish.
Need this built rather than just documented? See our services →