我有一个名为TopBroker
的CRM和一个Wordpress
站点。
我在现场使用了Contact form 7
。我想将联系表单7与Topbroker CRM
集成在一起,因此,如果用户填写联系表单并提交,则所有连续的数据都会自动插入到TopBroker CRM中。
有人知道我们该怎么做吗?
您可以使用wpcf7_before_send_mail
钩子和TopBrokerCRM API在CRM中插入数据:
对于TopBrokerCRM API,需要以下参数:authcode
,firstname
,lastname
,address
,city
,state
,zip
,phone
和email
。
因此联系表必须具有这些字段。
之后,使用如下所示的钩子:
add_action( 'wpcf7_before_send_mail', 'wpcf7_topbroker' );
function wpcf7_topbroker( $contact_form ) {
$submission = WPCF7_Submission::get_instance();
$posted_data = $submission->get_posted_data();
if( $posted_data ) {
$curl_data = array(
'authcode' => $posted_data[ 'authcode' ],
'firstname' => $posted_data[ 'firstName' ],
'lastname' => $posted_data[ 'lastName' ],
'address' => $posted_data[ 'address' ],
'city' => $posted_data[ 'city' ],
'state' => $posted_data[ 'state' ],
'zip' => $posted_data[ 'zip' ],
'phone' => $posted_data[ 'phone' ],
'email' => $posted_data[ 'emai' ]
);
$curl_string = http_build_query( $curl_data );
$options = array(
CURLOPT_RETURNTRANSFER => true, // return web page
CURLOPT_ENCODING => "", // handle all encodings
CURLOPT_TIMEOUT => 120, // timeout on response
CURLOPT_MAXREDIRS => 10, // stop after 10 redirects
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => $curl_string,
CURLOPT_HTTPHEADER => array(
"cache-control: no-cache",
'Content-Length: 0'
)
);
$ch = curl_init();
curl_setopt_array( $ch, $options );
$content = curl_exec( $ch);
$err = curl_errno( $ch );
$errmsg = curl_error( $ch );
$header = curl_getinfo( $ch );
curl_close( $ch );
}
}