Description

Action cvm_post_insert runs after a new post is created as a result of an imported Vimeo video. Useful when new custom fields need to be filled for the posts created by WP plugin Vimeo Video Post.

Parameters

$post_id
(integer)(optional) The ID of the newly created WordPress post.

Default:None
$video_details
(array)(optional) Array containing the video details retrieved from Vimeo (video ID, duration, thumbnails, tags, etc).

Default:None
$theme
(array/boolean)(optional) If user chose to import video as WP theme post (WP theme must be compatible with the plugin), this variable will hold the theme details into an array. In all other cases, this variable will have value (boolean)FALSE

Default:None
$post_type
(string)(optional) The post type of the newly create WordPress post.

Default:None

Examples

1. Fill video duration (in seconds) in custom field “video_duration“.

function custom_field_video_duration( $post_id, $video ){
    add_post_meta( $post_id, 'video_duration', $video['duration'] );
}
add_action( 'cvm_post_insert', 'custom_field_video_duration', 10, 2 );

2. Change post status to “draft” if Vimeo embed privacy for the currently imported video is “private”.

function draft_private_embeds( $post_id, $video ){
    if( 'private' == $video['embed_privacy'] ){
        wp_update_post( array( 'ID' => $post_id, 'post_status' => 'draft' ) );
    }
}
add_action( 'cvm_post_insert', 'draft_private_embeds', 10, 2 );

$video['embed_privacy'] can have the following values:

  • (string) public – video can be embedded anywhere
  • (string) private – no video embedding allowed
  • (string) whitelist – video can be embedded only on domains specified by the uploader