Skip to main content

benecaster_content_calendar_before_save_item

Action Premium content-calendar

Fires before a Content Calendar content item is written: when one is created or edited on the Calendar screen or over the REST API, imported from an .ics file, or made from an idea on the Ideas board, and when the episode it is linked to moves to another show and the item goes with it.

Parameters

Name Type Default Description
$item array — The content item about to be stored. Its fields are listed in the walkthrough below.
$context string — `create` (`id` is then 0), `import` (made by an iCal import; `id` is then 0), `promote` (made from an idea on the Ideas board; `id` is then 0), `update`, or `episode_move` (`show_id` is the new show)

Example

add_action( 'benecaster_content_calendar_before_save_item', function ( array $item, string $context ): void {
    if ( 'create' === $context ) {
        my_audit_log( 'calendar-item-creating', $item['show_id'], $item['title'] );
    }
}, 10, 2 );

Notes

Dates and times are the site's day and wall-clock time, never UTC. The episode_move context fires even while Content Calendar is off for every show. Walkthrough, with every field of $item: Run your own code when a Content Calendar content item is saved or deleted.

Affects

  • Calendar screen
  • POST benecaster-content-calendar/v1/shows/{show_id}/items
  • PUT/PATCH benecaster-content-calendar/v1/shows/{show_id}/items/{id}
  • POST benecaster-content-calendar/v1/shows/{show_id}/ical/import
  • POST benecaster-content-calendar/v1/shows/{show_id}/ideas/{id}/promote

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