Read and set the status of a task in an episode’s production plan, and run code when one changes
Each task of an episode’s production plan (see Read or change an episode’s production plan, change how a new plan starts, and run code when a plan is finalised) carries a status a person sets: not_started (every new task), in_progress, blocked or complete.
Draft, Late and Unassigned are not statuses. They are worked out when shown, and never stored or accepted. A task is Late when its due date (publish date + offset_days, in the site’s time zone) is before today and it is not complete. Due today is not Late, and without a publish date nothing is Late.
PUT /benecaster-podcast-workflow/v1/shows/{show_id}/episodes/{episode_id}/plan/tasks/{task_id}/statussends{ status }and saves it at once, whether the plan is a draft or final. It refuses with400 benecaster_podcast_workflow_invalid_task_status,404 benecaster_podcast_workflow_no_plan,404 benecaster_podcast_workflow_task_not_foundand the Workbench’s per-show checks, and answers asGET …/plandoes.PUT …/plannever sets a status: it keeps each task’s byid, and a new task startsnot_started.- The plan’s figures are
summaryonGET …/plan, andtaskson each row ofGET …/shows/{show_id}/episodesand on theepisodeofGET …/workbench(see Read the Podcast Workflow Workbench over REST), null without a plan:{ total, complete, late, blocked, finalised, next }.nextis the task notcompletewith the lowestoffset_days(on a tie, the one higher in the plan), as{ id, name, offset_days, due_date, late }withdue_dateasY-m-dor null;nextis null when every task is complete. - benecaster_podcast_workflow_before_task_status_change and benecaster_podcast_workflow_after_task_status_change are actions,
( int $episode_id, string $task_id, string $new_status, string $old_status, int $show_id ), around a change, and only a change. The plan’s own save actions fire too.
Code
<?php
add_action( 'benecaster_podcast_workflow_after_task_status_change', function ( int $episode_id, string $task_id, string $new_status, string $old_status, int $show_id ): void {
if ( 'blocked' === $new_status ) {
my_plugin_alert_producer( $episode_id, $task_id );
}
}, 10, 5 );
Hooks Used
Need this built rather than just documented? See our services →