【问题标题】:Wordpress Gravity Forms Dropbox link not found in $entry object在 $entry 对象中找不到 Wordpress Gravity Forms Dropbox 链接
【发布时间】:2020-02-13 16:18:53
【问题描述】:

我正在使用 WordPress 重力表单和 Dropbox 插件在 Dropbox 上上传文件 我正在尝试使用 PHP 提交表单后检索 Dropbox 链接 正如文档所说,我应该能够在条目对象中找到链接 https://docs.gravityforms.com/gf_field_dropbox/#-entry-value 但是我只找到了 WordPress 上传链接,尽管当我查看我的条目时,保管箱链接就在那里 这是我在当前主题的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】:

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

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

    【讨论】:

      猜你喜欢
      • 2018-11-01
      • 2020-06-17
      • 2014-12-08
      • 2015-02-10
      • 2017-07-25
      • 1970-01-01
      • 1970-01-01
      • 2014-11-02
      • 2014-11-27
      相关资源
      最近更新 更多