为了账号安全,请及时绑定邮箱和手机立即绑定

字压重力表单投递箱链接未在$entry对象中找到

字压重力表单投递箱链接未在$entry对象中找到

PHP
冉冉说 2022-09-17 22:32:49
我正在使用WordPress重力表单和Dropbox插件在Dropbox上上传文件,我试图在使用PHP提交表单后检索Dropbox链接,正如文档所说,我应该能够在 https://docs.gravityforms.com/gf_field_dropbox/#-entry-value 的条目中找到该链接,但我只能找到WordPress上传链接,尽管当我查看我的条目时,dropbox链接坐在那里很好,这是我在函数中使用的代码.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 生成的链接?
查看完整描述

1 回答

?
拉风的咖菲猫

TA贡献1995条经验 获得超2个赞

设法使用此获取生成的Dropbox链接


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





    }



}


查看完整回答
反对 回复 2022-09-17
  • 1 回答
  • 0 关注
  • 143 浏览

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号