从重力形式接收 2 个 url,并将它们分别放入 2 个不同的列中

Receiving 2 urls from gravity forms and putting them separately into 2 different columns

我正在做一个小项目,我将从 wordpress 中的重力表单插件接收信息,然后将该信息解析为 google 工作表。 到目前为止,我能够毫无问题地做到这一点。当其中一个字段是文件上传字段(要上传的最大文件数为 2)时,会出现此问题。链接像这样放在一起,例如:"www.example.org/wp-content-uploads/gravityforms/image1.jpg","www.example.org/wp-content-uploads/gravityforms/image1.jpg"

我希望它做的是 !(http://imgur.com/a/BUXvn)!

它将在医生源列(第3列)中显示完整的字符串,然后使用逗号作为分隔符将其拆分为2个并显示在医生图像1和医生图像2中。

这是我用来在 php 中进行解析的代码。

add_action('gform_after_submission_1', 'add_to_google_spreadsheet', 10,        2);
function add_to_google_spreadsheet($entry, $form) {
// This is the web app URL of your Google Script create in previous step
$post_url =  'https://script.google.com/macros/s/AKfycbwFTe3H0w8bp_2yviORAGhNZzIwvmKmdaCHf KEOdORwjO6pJPQ/exec';
// Put all the form fields (names and values) in this array
$doctor=('doctor source => rgar($entry,3)');
$doctorimage= explode(",",$doctor);
$body = array('first name' => rgar($entry, '1'), 'last name' =>  rgar($entry, '2'),'doctor source' => rgar($entry, '3'),'doctor image1' =>  rgar($doctorimage[0], '4'),'doctor image2' => rgar($doctorimage[1], '5'),);
// Send the data to Google Spreadsheet via HTTP POST request
$request = new WP_Http();
$response = $request->request($post_url, array('method' => 'POST',   'sslverify' => false, 'body' => $body));
} 

rgar : 重力形式用法 Returns 数组中的一个值 用法 rgar( $array, $name );

对于任何想做同样事情的人,这里是我使用的指南:https://ctrlq.org/code/20047-gravity-forms-to-google-spreadsheet

我认为只有一些小的格式/逻辑问题需要解决。

根据您提供的信息,这是我目前的最佳尝试。有一些问题可能会改变回复:

// Adjust this line to simply GET the field for the doctor images
$doctor =rgar( $entry, 3 );
// Now, given the revision above, this line should properly explode the images
$doctorimage = explode( ',', $doctor );
// Adjust the below to put the images in (no need for rgar for them here)
$body = array(
    'first name'    => rgar( $entry, '1' ), 
    'last name'     => rgar( $entry, '2' ),
    'doctor source' => rgar( $entry, '3' ),
    'doctor image1' => $doctorimage[0],
    'doctor image2' => $doctorimage[1]
);
// Send the data to Google Spreadsheet via HTTP POST request
//....

可能有所作为的问题:
1. 表格中的字段 3 是什么?根据您的代码,这是图像的两个网址 - 对吗?
2. 您的表格中是否有字段 4(和字段 5)?它们包含什么?
3. 您表单中应该是 "doctor source" 的字段是什么?