{"id":23,"date":"2024-04-27T13:35:03","date_gmt":"2024-04-27T13:35:03","guid":{"rendered":"https:\/\/faq.cinar-studio.ru\/?p=23"},"modified":"2024-04-27T23:25:15","modified_gmt":"2024-04-27T23:25:15","slug":"rabocha-integracziya-bitrix24-contact-form-7","status":"publish","type":"post","link":"https:\/\/faq.cinar-studio.ru\/?p=23","title":{"rendered":"\u0420\u0430\u0431\u043e\u0447\u0430\u044f \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u044f Bitrix24 + Contact Form 7 (WordPress)"},"content":{"rendered":"<blockquote><p>\u041d\u0410\u0421\u0422\u0420\u041e\u0419\u041a\u0410 \u0414\u0410\u041d\u041d\u041e\u0413\u041e \u0421\u041a\u0420\u0418\u041f\u0422\u0410 \u041f\u041b\u0410\u0422\u041d\u0410\u042f! \u041f\u0420\u0415\u0414\u0423\u041f\u0420\u0415\u0416\u0414\u0410\u0419\u0422\u0415 \u041f\u041c!<\/p>\n<p>\u0417\u0410\u041f\u0420\u041e\u0421\u0418\u0422\u042c \u0423 \u041f\u041c \u041b\u041e\u0413\u0418\u041d, \u041f\u0410\u0420\u041e\u041b\u042c \u0418 \u041f\u041e\u0414\u0414\u041e\u041c\u0415\u041d \u041e\u0422 CRM BITRIX24!<\/p><\/blockquote>\n<p>\u0412\u0421\u0422\u0410\u0412\u041b\u042f\u0415\u041c \u0412 functions.php<\/p>\n<p>\/\/\u0412\u044b\u0437\u044b\u0432\u0430\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442\u0430 \u0434\u0430\u043d\u043d\u044b\u0445<br \/>\nadd_action( &#8216;wpcf7_mail_sent&#8217;, &#8216;your_wpcf7_mail_sent_function&#8217; );<br \/>\nfunction your_wpcf7_mail_sent_function( $contact_form ) {<\/p>\n<p>\/\/\u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043a \u0441\u0435\u0440\u0432\u0435\u0440\u0443 CRM<br \/>\ndefine(&#8216;CRM_HOST&#8217;, &#8216;\u043f\u043e\u0434\u0434\u043e\u043c\u0435\u043d.bitrix24.ru&#8217;); \/\/ \u0412\u0430\u0448 \u0434\u043e\u043c\u0435\u043d CRM \u0441\u0438\u0441\u0442\u0435\u043c\u044b<br \/>\ndefine(&#8216;CRM_PORT&#8217;, &#8216;443&#8217;); \/\/ \u041f\u043e\u0440\u0442 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 CRM. \u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e<br \/>\ndefine(&#8216;CRM_PATH&#8217;, &#8216;\/crm\/configs\/import\/lead.php&#8217;); \/\/ \u041f\u0443\u0442\u044c \u043a \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0443 lead.rest<\/p>\n<p>\/\/\u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044f \u0432 CRM<br \/>\ndefine(&#8216;CRM_LOGIN&#8217;, \u043b\u043e\u0433\u0438\u043d&#8217;); \/\/ \u041b\u043e\u0433\u0438\u043d \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0412\u0430\u0448\u0435\u0439 CRM \u043f\u043e \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044e \u043b\u0438\u0434\u0430\u043c\u0438<br \/>\ndefine(&#8216;CRM_PASSWORD&#8217;, &#8216;\u043f\u0430\u0440\u043e\u043b\u044c&#8217;); \/\/ \u041f\u0430\u0440\u043e\u043b\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0412\u0430\u0448\u0435\u0439 CRM \u043f\u043e \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044e \u043b\u0438\u0434\u0430\u043c\u0438<\/p>\n<p>\/\/\u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0437 Contact Form 7<br \/>\n$title = $contact_form-&gt;title;<br \/>\n$posted_data = $contact_form-&gt;posted_data;<br \/>\n$submission = WPCF7_Submission::get_instance();<br \/>\n$posted_data = $submission-&gt;get_posted_data();<br \/>\n\/\/\u0434\u0430\u043b\u0435\u0435 \u043c\u044b \u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u0432\u0432\u0435\u0434\u0435\u043d\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 Contact Form 7<br \/>\n$messageTheme = $posted_data[&#8216;your-theme&#8217;]; \/\/\u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442\u044b\u0432\u0430\u0435\u043c \u043f\u043e\u043b\u0435 [your-name]<br \/>\n$firstName = $posted_data[&#8216;your-name&#8217;]; \/\/\u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442\u044b\u0432\u0430\u0435\u043c \u043f\u043e\u043b\u0435 [your-name]<br \/>\n$myphone = $posted_data[&#8216;your-tel&#8217;]; \/\/\u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442\u044b\u0432\u0430\u0435\u043c \u043f\u043e\u043b\u0435 [your-phone]<br \/>\n$message = &#8221;; \/\/\u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442\u044b\u0432\u0430\u0435\u043c \u043f\u043e\u043b\u0435 [your-message]<\/p>\n<p>\/\/\u0441\u043e\u043f\u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u043f\u043e\u043b\u0435\u0439 Bitrix24 \u0441 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0438\u0437 Contact Form 7<br \/>\n$postData = array(<br \/>\n&#8216;TITLE&#8217; =&gt; &#8216;\u0417\u0430\u044f\u0432\u043a\u0430 \u0441 \u0441\u0430\u0439\u0442\u0430 \u0441 \u0444\u043e\u0440\u043c\u044b: &#8216; . $messageTheme, \/\/ \u0423\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0441\u0432\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435<br \/>\n&#8216;NAME&#8217; =&gt; $firstName,<br \/>\n&#8216;PHONE_WORK&#8217; =&gt; $myphone,<br \/>\n&#8216;COMMENTS&#8217; =&gt; $message,<br \/>\n);<\/p>\n<p>\/\/\u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0437 Contact Form 7 \u0432 Bitrix24<br \/>\nif (defined(&#8216;CRM_AUTH&#8217;)) {<br \/>\n$postData[&#8216;AUTH&#8217;] = CRM_AUTH;<br \/>\n} else {<br \/>\n$postData[&#8216;LOGIN&#8217;] = CRM_LOGIN;<br \/>\n$postData[&#8216;PASSWORD&#8217;] = CRM_PASSWORD;<br \/>\n}<\/p>\n<p>$fp = fsockopen(&#8220;ssl:\/\/&#8221;.CRM_HOST, CRM_PORT, $errno, $errstr, 30);<br \/>\nif ($fp) {<br \/>\n$strPostData = &#8221;;<br \/>\nforeach ($postData as $key =&gt; $value)<br \/>\n$strPostData .= ($strPostData == &#8221; ? &#8221; : &#8216;&amp;&#8217;).$key.&#8217;=&#8217;.urlencode($value);<\/p>\n<p>$str = &#8220;POST &#8220;.CRM_PATH.&#8221; HTTP\/1.0\\r\\n&#8221;;<br \/>\n$str .= &#8220;Host: &#8220;.CRM_HOST.&#8221;\\r\\n&#8221;;<br \/>\n$str .= &#8220;Content-Type: application\/x-www-form-urlencoded\\r\\n&#8221;;<br \/>\n$str .= &#8220;Content-Length: &#8220;.strlen($strPostData).&#8221;\\r\\n&#8221;;<br \/>\n$str .= &#8220;Connection: close\\r\\n\\r\\n&#8221;;<\/p>\n<p>$str .= $strPostData;<\/p>\n<p>fwrite($fp, $str);<\/p>\n<p>$result = &#8221;;<br \/>\nwhile (!feof($fp))<br \/>\n{<br \/>\n$result .= fgets($fp, 128);<br \/>\n}<br \/>\nfclose($fp);<\/p>\n<p>$response = explode(&#8220;\\r\\n\\r\\n&#8221;, $result);<\/p>\n<p>$output = &#8216;&lt;pre&gt;&#8217;.print_r($response[1], 1).'&lt;\/pre&gt;&#8217;;<br \/>\n} else {<br \/>\necho &#8216;Connection Failed! &#8216;.$errstr.&#8217; (&#8216;.$errno.&#8217;)&#8217;;<br \/>\n}<\/p>\n<p>}<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u041d\u0410\u0421\u0422\u0420\u041e\u0419\u041a\u0410 \u0414\u0410\u041d\u041d\u041e\u0413\u041e \u0421\u041a\u0420\u0418\u041f\u0422\u0410 \u041f\u041b\u0410\u0422\u041d\u0410\u042f! \u041f\u0420\u0415\u0414\u0423\u041f\u0420\u0415\u0416\u0414\u0410\u0419\u0422\u0415 \u041f\u041c! \u0417\u0410\u041f\u0420\u041e\u0421\u0418\u0422\u042c \u0423 \u041f\u041c \u041b\u041e\u0413\u0418\u041d, \u041f\u0410\u0420\u041e\u041b\u042c \u0418 \u041f\u041e\u0414\u0414\u041e\u041c\u0415\u041d \u041e\u0422 CRM BITRIX24! \u0412\u0421\u0422\u0410\u0412\u041b\u042f\u0415\u041c \u0412 functions.php \/\/\u0412\u044b\u0437\u044b\u0432\u0430\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 add_action( &#8216;wpcf7_mail_sent&#8217;, &#8216;your_wpcf7_mail_sent_function&#8217; ); function your_wpcf7_mail_sent_function( $contact_form ) { \/\/\u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043a \u0441\u0435\u0440\u0432\u0435\u0440\u0443 CRM define(&#8216;CRM_HOST&#8217;, &#8216;\u043f\u043e\u0434\u0434\u043e\u043c\u0435\u043d.bitrix24.ru&#8217;); \/\/ \u0412\u0430\u0448 \u0434\u043e\u043c\u0435\u043d CRM \u0441\u0438\u0441\u0442\u0435\u043c\u044b define(&#8216;CRM_PORT&#8217;, &#8216;443&#8217;); \/\/ \u041f\u043e\u0440\u0442 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 CRM. \u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e define(&#8216;CRM_PATH&#8217;, &#8216;\/crm\/configs\/import\/lead.php&#8217;); [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[3],"tags":[],"acf":[],"_links":{"self":[{"href":"https:\/\/faq.cinar-studio.ru\/index.php?rest_route=\/wp\/v2\/posts\/23"}],"collection":[{"href":"https:\/\/faq.cinar-studio.ru\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/faq.cinar-studio.ru\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/faq.cinar-studio.ru\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/faq.cinar-studio.ru\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=23"}],"version-history":[{"count":9,"href":"https:\/\/faq.cinar-studio.ru\/index.php?rest_route=\/wp\/v2\/posts\/23\/revisions"}],"predecessor-version":[{"id":37,"href":"https:\/\/faq.cinar-studio.ru\/index.php?rest_route=\/wp\/v2\/posts\/23\/revisions\/37"}],"wp:attachment":[{"href":"https:\/\/faq.cinar-studio.ru\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=23"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/faq.cinar-studio.ru\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=23"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/faq.cinar-studio.ru\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=23"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}