cbc unpublish video

Description

Fires after a video post was unpublished because its video is no longer available on YouTube. It runs in two cases:

  • the daily check of the Unpublish posts whose video is no longer available on YouTube option (Settings, tab Post options) sets the post to Pending review;
  • the Update videos tool changes the post to draft or pending review, as chosen under Videos no longer on YouTube (since 2.3.0).

Since version 2.3.1, a post is unpublished only when YouTube confirms that the video was deleted, made private, rejected or can’t be embedded. An exceeded quota, an invalid API key or another YouTube error never unpublishes it.

Parameters

$post
(WP_Object)(optional) The current WP_Post object

Default:None
$video
(array|WP_Error)(optional) The video details array returned by YouTube API, or a WP_Error when the video was not found

Default:None

Examples

Send an e-mail to blog admin each time a video gets unpublished because YouTube API returns the video as non-public or deleted.

/**
 * E-mail administrator every time a video gets unpublished
 * @param WP_Post $post
 * @param array $video
 */
function video_unpublish_manager( $post, $video ){
	wp_mail( 
		get_bloginfo( 'admin_email' ), 
		__('Unpublished video'), 
		sprintf( __('Post ID %d was unpublished.'), $post->ID ) 
	);
}
add_action( 'cbc_unpublish_video', 'video_unpublish_manager', 10, 2 );

Start importing in minutes

Bring your YouTube content into WordPress and let it update itself. Includes automatic updates and support.