Skip to main content

Run your own code when a Content Calendar idea is saved, deleted or rearranged

Premium Intermediate Content Calendar

An idea is one card on a show’s Ideas board, an undated backlog: { id, show_id, type, type_name, title, notes, position, created_by, created_at, updated_at }.

  • type is one of the show’s content type keys (see Read or change a show’s Content Calendar content types), or '' while the podcaster has not decided it. type_name is the name typed for an Other idea, '' otherwise.
  • position orders the board, lowest first. A new idea goes first, one less than the lowest.
  • created_at and updated_at are UTC Y-m-d H:i:s.
  • An idea has no date and no episode.

Saving and deleting. Four actions, all ( array $idea, string $context ): benecaster_content_calendar_before_save_idea, benecaster_content_calendar_after_save_idea, benecaster_content_calendar_before_delete_idea and benecaster_content_calendar_after_delete_idea. Save $context is create (before the write, id is 0) or update. Delete $context is delete, or promote when the idea leaves the board because it was put on the calendar. By then the new content item has already been saved, with $context promote (see Run your own code when a Content Calendar content item is saved or deleted).

Rearranging. Two actions, ( int $show_id, array $ids ), $ids being every idea of the show, first to last: benecaster_content_calendar_before_reorder_ideas and benecaster_content_calendar_after_reorder_ideas.

An after hook fires only when the write succeeded.

Code

<?php
add_action( 'benecaster_content_calendar_after_delete_idea', function ( array $idea, string $context ): void {
    if ( 'promote' === $context ) {
        my_log( sprintf( 'Idea "%s" went on show %d\'s calendar.', $idea['title'], $idea['show_id'] ) );
    }
}, 10, 2 );

View on GitHub →

Hooks Used

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