1
我有一個帶有3表格的網站,但這些表格中只有兩個必須將信息輸入到Salesforce數據庫中。如何定義哪些表單應該使用鉤子,哪些應該不經過鉤子?限制聯繫表格7掛鉤(在發送之前)至特定表格
按照我正在使用的代碼:
add_action('wpcf7_before_send_mail', 'my_conversion');
function my_conversion($contact_form) {
$title = $contact_form->title;
$submission = WPCF7_Submission::get_instance();
if ($submission) {
$posted_data = $submission->get_posted_data();
}
$email = $posted_data["your-email"];
$name = $posted_data["your-name"];
$last = $posted_data["your-lastname"];
$phone = $posted_data["tel-71"];
$description = $posted_data["your-message"];
$post_items[] = 'oid=00D4000000xxxxx';
$post_items[] = 'first_name=' . $name;
$post_items[] = 'last_name=' . $last;
$post_items[] = 'company=';
$post_items[] = 'email=' . $email;
$post_items[] = 'phone=' . $phone;
$post_items[] = 'description=' . $description;
$post_items[] = '00N4000000XXXX=' . "Shopping";
$post_items[] = '00N4000000xxxxxx=' . "1";
$post_items[] = 'external=1';
$post_items[] = 'lead_source=Shopping';
$post_string = implode ('&', $post_items);
$ch = curl_init('https://www.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8');
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_string);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_exec($ch); // Post to Salesforce
curl_close($ch); // close cURL resource
}
謝謝您的幫助。
我找到了這樣的功能: '如果($ contact_form-> ID == $ myform_id!) 回報;' 但我還不是很瞭解PHP。我應該在哪裏輸入這一行?你能幫我嗎? 再次感謝。 –
我的確如此: 'add_action('wpcf7_before_send_mail','my_conversion'); 函數my_conversion($ contact_form){ $ title = $ contact_form-> title; $ submission = WPCF7_Submission :: get_instance(); $ id = $ contact_form-> id(); \t \t if($ id == 68){submission-> skip_mail = true; } \t if($ id == 65){ $ posted_data = $ submission-> get_posted_data(); } (...)' 現在通常在Salesforce中記錄ID = 65的格式。但ID = 68不發送電子郵件,被填充的字段鎖定。我究竟做錯了什麼?有沒有人有任何想法? –
你好。我有一個解決方案,我不認爲這是最好的,但這是我做的: 我使用@takayukister建議的解決方案。在「$ contact_form-> title()」的情況下。 –