• Hi Ben,

    First of all, thanks for the effort you put into this GREAT plugin.

    I have one question (it was partially already addressed, but the solution was not clear to me): When uploading a file to youtube by a user, I collect other information on the form (name, description etc.) and save it to a custom post type Video. Now I want to do two things:
    1. Retrieve the youtube ID and store it in a field of the CPT Video.
    2. In addition to the video, also upload meta data (name, description) into the respective youtube fields.

    Your help is much appreciated.

    Thanks in advance,
    Yves

    https://www.ads-software.com/plugins/gravity-forms-advanced-file-uploader/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author ben.moody

    (@benmoody)

    Hi

    To retrieve the video ID you can use the following hook, this hook is called after the youtube upload and just before the id is saved into gravity forms:

    add_action(‘prso_gform_youtube_uploader_pre_update_meta’, ‘prso_get_youtube_id’);

    function prso_get_youtube_id( $field_values, $form_data ) {

    //$field_values is an array containing array of field_ids and video ids

    //$form_data contains info on the submitted form and entries

    }

    With those variables you should be able to do whatever you like with the youtube id after a form is submitted and videos have been uploaded to youtube

    I know this thread is very old, but posting my answer to part 1 of OP’s question because it’s impossible to find the answer online.

    This is the code that worked for me & saved the youtube ID as a custom field.

    add_action('prso_gform_youtube_uploader_pre_update_meta', 'prso_get_youtube_id', 10, 2);
    function prso_get_youtube_id( $field_values, $form_data ) {
    $postID = $form_data[ 'gforms_entry' ]['post_id'];
    $videoID = $field_values[2][0]['video_id'];
    update_post_meta($postID, 'vidid', $videoID);
    }
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Save Youtube ID in a custom field’ is closed to new replies.