在$ entry对象中找不到Wordpress重力形式Dropbox链接

问题描述 投票:1回答:1

我正在使用WordPress重力形式和Dropbox插件在Dropbox上上传文件我正在尝试使用PHP提交表单后检索保管箱链接正如文档所说,我应该能够在入口对象中找到链接https://docs.gravityforms.com/gf_field_dropbox/#-entry-value但是我只能找到WordPress上载链接,尽管当我查看条目时,dropbox链接就位于那里这是我当前主题的functions.php中使用的代码

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);

}

提交表单后,我有什么方法可以访问Dropbox生成的链接?

php wordpress gravity-forms-plugin
1个回答
0
投票

设法使用此方法获得生成的保管箱链接

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);




    }


}
© www.soinside.com 2019 - 2024. All rights reserved.