Skip to content

Instantly share code, notes, and snippets.

@gdarko
Last active September 18, 2023 00:15
Show Gist options
  • Save gdarko/e239e9ec6af9d57a234760faa2cb9f14 to your computer and use it in GitHub Desktop.
Save gdarko/e239e9ec6af9d57a234760faa2cb9f14 to your computer and use it in GitHub Desktop.
Vimeify (Video Uploads for VImeo) - Creates post type entry on front-end upload
<?php
add_action('dgv_frontend_after_upload', function($data){
/**
* Example of the $data array:
* $data = array(
* 'vimeo_title' => $vimeo_title,
* 'vimeo_description' => $vimeo_description,
* 'vimeo_id' => $vimeo_id,
* 'vimeo_size' => $file_size,
* 'source' => array(
* 'software' => 'CustomForms',
* 'entry_id' => null,
* 'field_id' => $field_id,
* 'form_id' => $form_id,
* );
); */
$record_id = wp_insert_post([
'post_type' => 'your-post-type-key',
'post_title' => $data['vimeo_title'],
'post_content' => $data['vimeo_description'],
'post_status' => 'publish',
]);
if(!is_wp_error($record_id)) {
update_post_meta($record_id, 'vimeo_id', $data['video_id'] );
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment