Home » Php » php – WordPress Gravity Forms Dropbox link not found in $entry object

php – WordPress Gravity Forms Dropbox link not found in $entry object

Posted by: admin February 25, 2020 Leave a comment

Questions:

I’m using WordPress gravity forms and dropbox addon to upload files on dropbox
I am trying to retrieve the dropbox link after form submission using PHP
As docs said i should be able to find the link in the entry object
https://docs.gravityforms.com/gf_field_dropbox/#-entry-value
but I only find the WordPress upload link although when I view my entry the dropbox link is sitting there fine
and here is the code I am using in the functions.php of my current theme

add_action( 'gform_after_submission', 'post_to_third_party', 10, 2 );
function post_to_third_party( $entry, $form ) {

    $value = rgar( $entry, '158' ); // id of the field that holds the dropbox link
    $files = json_decode( $value, true );
    foreach ( $files as $file ) {
        print_r($file);
    }
    foreach($entry as $child) { // also trying to print all entry properties but found nothing
        echo $child . "<br>";
    }

    $value1 = GF_Field_Dropbox::get_value_export( $entry, '158' ); // trying export function in the docs but gives the same as first $value
    print_r($value1);

}

is there any way I can access the dropbox generated links after form submission?

How to&Answers:

managed to get the generated dropbox link using this

add_action( 'gform_dropbox_post_upload', 'get_dropbox_urls', 10, 3 );
function get_dropbox_urls( $feed, $entry, $form ) {

    print_r('started get drobbox');
    foreach( $form['fields'] as &$field )  {

        // NOTE: Replace 3 with your Dropbox field id.
        $field_id = 158;
        print_r($field_id,'the field id', $field);
        if ( $field->id != $field_id ) {
            continue;
        }

        // Get the field value.
        $field_value = $entry[ $field->id ];

        // Exit if field value is empty.
        if ( rgblank( $field_value ) ) {
            return;
        }

        // Decode JSON string.
        $files = json_decode( stripslashes_deep( $field_value ), true );
        print_r($files);




    }


}