首页 > 解决方案 > 有没有办法将数据从 WP Formidable Forms 中的转发器字段传输到 ActiveCampaign?

问题描述

目前,我正在尝试将数据从 Wordpress 强大表单中的转发器字段传输到称为 ActiveCampaign 的 CRM 系统中的列表。

不幸的是,ActiveCampaign 插件无法识别转发器字段内的字段。

导出子表单时,我得到了我想要的。有没有办法在创建条目后立即导出此文件?

任何支持将不胜感激。

标签: wordpressautomationzapierformidableactivecampaign

解决方案


也许这个链接可以帮助你:https ://www.fdmdigital.co.uk/export-a-form-entry-to-csv-on-submit/

add_action('frm_after_create_entry', 'create_csv', 30, 2);
function create_csv($entry_id, $form_id) {
if ($form_id == 1234) { //replace 1234 with the id of the form

    // Collect the form data - Add a new row for each field you want to export and give it a unique name
    $firstName = isset($_POST['item_meta'][1537]) ? $_POST['item_meta'][1537] : '';
    $lastName = isset($_POST['item_meta'][1538]) ? $_POST['item_meta'][1538] : '';
    $email = isset($_POST['item_meta'][1540]) ? $_POST['item_meta'][1540] : '';
    $organizationId = isset($_POST['item_meta'][1547]) ? $_POST['item_meta'][1547] : '';
    $organizationName = isset($_POST['item_meta'][1548]) ? $_POST['item_meta'][1548] : '';
    $createdAt = isset($_POST['item_meta'][1555]) ? $_POST['item_meta'][1555] : '';

    // The header row of the CSV - Add a name for each field in the form
    $header = "firstName,lastName,email,organizationId,organizationName,createdAt\n";

    // The data of the CSV - Add each of the form fields listed above
    $data = "$firstName,$lastName,$email,$organizationId,$organizationName,$createdAt\n";

    /*
     * The file name of the CSV.
     * 
     * NB: To save a single file per entry you will need to make the file name unique 
     * This can be done using the entry ID or the date & time stamp by including the hour, minutes & seconds. 
     * E.g at 12:38:43 the file will be named "TestUser-21-02-05-12-38-43-request.csv".
     * One second later the time (and file name) will be "12:38:44".
     * Then a new file "TestUser-21-02-05-12-38-44-request.csv" will be created.
     * How you name the file will determine if you have a new file for each entry, a new file per user or a single file with all entry data.
     */

    $fileName = dirname(__DIR__, 3) . "/your-project-folder/" . $refUserId . "-" .$createdAt . "-request" . ".csv";

    /*
     * Create the CSV file.
     * If file exists, append the data to it. Otherwise create a new file.
     */
    if (file_exists($fileName)) {
        // Add only data. The header is already added in the existing file.
        file_put_contents($fileName, $data, FILE_APPEND);
    } else {
        // Add CSV header and data.
        file_put_contents($fileName, $header.$data);
    }
}

}


推荐阅读