dongtang1909 2014-04-10 21:59
浏览 142
已采纳

Wordpress:将CRM(solve360)与Contact Form 7集成

I am trying to let a contact form (Contact Form 7) on a WordPress site create new contacts in my CRM program (solve360). To make it easier, I also activated a plugin (Forms: 3rd Party Integration) in which I defined a submission url and field mapping. Part of it works, but I am missing something simple here...

When pressing the send button, the data is sent to an email address (success) and to solve360 (not yet successfully). I actually receive a message that a new contact was created in solve360, however all the fields are empty. So I am guessing the problem is that the form fields are not properly transferred to the solve360 fields. However, I am using this template from solve360:

 // REQUIRED Edit with the email address you login to Solve360 with
 define('USER', '****************');
 // REQUIRED Edit with token, Solve360 menu > My Account > API Reference > API Token
 define('TOKEN', '*****************');

 // Get request data
 $requestData = array();
 parse_str($_SERVER['QUERY_STRING'], $requestData);

 // Configure service gateway object
 require 'Solve360Service.php';
 $solve360Service = new Solve360Service(USER, TOKEN);

 //
 // Preparing the contact data
 //
 $contactFields =      array('firstname','lastname','businessemail','businessphonedirect','name','homeaddress','cus     tom10641628','custom11746174','custom13346238');
 $contactData = array();
 // adding not empty fields
 foreach ($contactFields as $solve360FieldName => $requestFieldName) {
if ($requestData[$requestFieldName]) {
    $contactData[$solve360FieldName] = $requestData[$requestFieldName];
}
 }

 //
 // Saving the contact
 //
 // If there was business email provided:
 // check if the contact already exists by searching for a matching email address.
 // if a match is found update the existing contact, otherwise create a new one.
 //
 if ($contactData['businessemail']) {
$contacts = $solve360Service->searchContacts(array(
    'filtermode' => 'byemail',
    'filtervalue' => $contactData['businessemail'],
));
 }
 if (isset($contacts) && (integer)$contacts->count > 0) {
     $contactId = (integer)current($contacts->children())->id;
     $contactName = (string)current($contacts->children())->name;
     $contact = $solve360Service->editContact($contactId, $contactData);
 } else {
     $contact = $solve360Service->addContact($contactData);
     $contactName = (string)$contact->item->name;
     $contactId = (integer)$contact->item->id;
 }

 if (isset($contact->errors)) {
     // Email the error
     mail(
         USER,
         'Error while adding contact to Solve360',
         'Error: ' . $contact->errors->asXml()
     );
     die ('System error');
 } else {
// Email the result
     mail(
    USER,
    'Contact posted to Solve360',
    'Contact "' . $contactName . '" https://secure.solve360.com/contact/' . $contactId .      ' was posted to Solve360'
);
 }

In their example, they use a contact form with method="get" instead of method="post", however in the user interface of Contact Form 7, I believe the method is fixed to "post". Could this be the problem?

Or is there a different issue? Note that an empty contact is created at the moment. I can provide field mapping details and Forms 3rd party integration does allow hooks, if that helps in anyway.

Any help would be really appreciated! Thanks.

  • 写回答

1条回答 默认 最新

  • douqiaolong0528 2014-05-13 15:54
    关注

    I discovered that the action method (POST) of the 3rd party plugin was not matching the expected action method (GET) of the Solve360 script. Therefore, I had to remove the following from the script:

    // Get request data
    $requestData = array();
    parse_str($_SERVER['QUERY_STRING'], $requestData);
    

    and change the following piece of code from

    // adding not empty fields
    foreach ($contactFields as $solve360FieldName => $requestFieldName) {
        if ($requestData[$requestFieldName]) {
             $contactData[$solve360FieldName] = $requestData[$requestFieldName];
        }
    }
    

    to

     // adding not empty fields
     foreach ($contactFields as $solve360FieldName => $requestFieldName) {
         if ($_POST[$requestFieldName]) {
             $contactData[$solve360FieldName] = $_POST[$requestFieldName];
         }
     }
    

    Hope this will help someone who is connecting Contact Form 7 to their Solve360 database.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100