{"id":2164,"date":"2012-10-18T21:46:36","date_gmt":"2012-10-18T19:46:36","guid":{"rendered":"http:\/\/thomasdt.com\/?p=12"},"modified":"2012-10-18T21:46:36","modified_gmt":"2012-10-18T19:46:36","slug":"a-contact-form-7-to-trello-process","status":"publish","type":"post","link":"https:\/\/rationalk.ch\/blog\/a-contact-form-7-to-trello-process\/","title":{"rendered":"A Contact Form 7 to Trello Process"},"content":{"rendered":"<p>The idea is to add a <a href=\"http:\/\/trello.com\">trello<\/a> card to your trello board anytime you receive an email from your <a href=\"contactform7.com\">contact form 7<\/a> wordpress plugin.<\/p>\n<p>Here is how you can do it :<\/p>\n<p>[php light=\u00a0\u00bbtrue\u00a0\u00bb]<br \/>\nadd_action( &lsquo;wpcf7_mail_sent&rsquo;, &lsquo;your_wpcf7_mail_sent_function&rsquo; );<\/p>\n<p>function your_wpcf7_mail_sent_function($contact_form){<br \/>\n\t$boardid=&rsquo;5040f5a3********d1c9ddc70&prime;;<br \/>\n\t$listid=&rsquo;507f1*********a7a4885&prime;;<br \/>\n\t$apiKey=&rsquo;6b93***********9146d740c2555798d8&prime;;<br \/>\n\t$token=&rsquo;6a50b26d45736cfc***********91a29b9bfc7a8c&rsquo;;<\/p>\n<p>\t$posted_data = $contact_form-&gt;posted_data;<br \/>\n\t$formid=$contact_form-&gt;id;<br \/>\n\tif ($formid==2){<br \/>\n\t\t\/\/ devis d\u00e9taill\u00e9 :<br \/>\n\t\t$name=&quot;Demande de devis d\u00e9taill\u00e9 &#8211; &quot;.$posted_data[&lsquo;url&rsquo;].&quot;\\n\\n&quot;;<br \/>\n\t\t$desc=&quot;De : &quot;.$posted_data[&lsquo;your-name&rsquo;].&quot; &quot;.$posted_data[&lsquo;your-email&rsquo;].&quot;&quot;.&quot;\\n\\n&quot;;<br \/>\n\t\t$desc.=&quot;Sujet : Demande de devis d\u00e9taill\u00e9&quot;.&quot;\\n\\n&quot;;<br \/>\n\t\t$desc.=&quot;Soci\u00e9t\u00e9 : &quot;.$posted_data[&lsquo;societe&rsquo;].&quot;\\n\\n&quot;;<br \/>\n\t\t$desc.=&quot;T\u00e9l\u00e9phone : &quot;.$posted_data[&lsquo;tel&rsquo;].&quot;\\n\\n&quot;;<br \/>\n\t\t$desc.=&quot;URL : &quot;.$posted_data[&lsquo;url&rsquo;].&quot;\\n\\n&quot;;<br \/>\n\t\t$desc.=&quot;Langue : &quot;.$posted_data[&lsquo;lang&rsquo;].&quot;\\n\\n&quot;;<br \/>\n\t\t$desc.=&quot;Cible : &quot;.$posted_data[&lsquo;cible&rsquo;].&quot;\\n\\n&quot;;<br \/>\n\t\t$desc.=&quot;Etat : &quot;.$posted_data[&lsquo;etat&rsquo;].&quot;\\n\\n&quot;;<br \/>\n\t\t$desc.=&quot;Ann\u00e9e de cr\u00e9ation : &quot;.$posted_data[&lsquo;annee&rsquo;].&quot;\\n\\n&quot;;<br \/>\n\t\t$desc.=&quot;Facebook : &quot;.$posted_data[&lsquo;facebook&rsquo;].&quot;\\n\\n&quot;;<br \/>\n\t\t$desc.=&quot;Twitter : &quot;.$posted_data[&lsquo;twitter&rsquo;].&quot;\\n\\n&quot;;<br \/>\n\t\t$desc.=&quot;Mots cl\u00e9s :&quot;.$posted_data[&lsquo;keywords&rsquo;].&quot;\\n\\n&quot;;<br \/>\n\t\t$desc.=&quot;Budget : &quot;.$posted_data[&lsquo;budget&rsquo;].&quot;\\n\\n&quot;;<br \/>\n\t\t$desc.=&quot;Informations suppl\u00e9mentaires : &quot;.$posted_data[&lsquo;your-message&rsquo;].&quot;\\n\\n&quot;;<br \/>\n\t\t$desc.=&quot;Affili\u00e9 :&quot;.$_COOKIE[&lsquo;from&rsquo;].&quot;\\n\\n&quot;;<br \/>\n\t\t$desc.=&quot;&#8211; Ce email a \u00e9t\u00e9 envoy\u00e9 via formulaire de contact #&quot;.$formid.&quot; de xxx &quot;.&quot;\\n\\n&quot;;<br \/>\n\t\tadd_to_trello($name,$desc,$listid,$boardid,$apiKey,$token);<br \/>\n\t}<br \/>\n\tif ($formid==3){<br \/>\n\t\t\/\/ devis rapide :<br \/>\n\t\t$name=&quot;Demande de devis rapide &#8211; &quot;.$posted_data[&lsquo;url&rsquo;].&quot;\\n\\n&quot;;<br \/>\n\t\t$desc=&quot;De : &quot;.$posted_data[&lsquo;your-name&rsquo;].&quot; &quot;.$posted_data[&lsquo;your-email&rsquo;].&quot;&quot;.&quot;\\n\\n&quot;;<br \/>\n\t\t$desc.=&quot;Sujet : Demande de devis rapide&quot;.&quot;\\n\\n&quot;;<br \/>\n\t\t$desc.=&quot;T\u00e9l\u00e9phone : &quot;.$posted_data[&lsquo;tel&rsquo;].&quot;\\n\\n&quot;;<br \/>\n\t\t$desc.=&quot;URL : &quot;.$posted_data[&lsquo;url&rsquo;].&quot;\\n\\n&quot;;<br \/>\n\t\t$desc.=&quot;Budget : &quot;.$posted_data[&lsquo;budget&rsquo;].&quot;\\n\\n&quot;;<br \/>\n\t\t$desc.=&quot;Affili\u00e9 :&quot;.$_COOKIE[&lsquo;from&rsquo;].&quot;\\n\\n&quot;;<br \/>\n\t\t$desc.=&quot;&#8211; Ce email a \u00e9t\u00e9 envoy\u00e9 via formulaire de contact #&quot;.$formid.&quot; de xxx &quot;.&quot;\\n\\n&quot;;<br \/>\n\t\tadd_to_trello($name,$desc,$listid,$boardid,$apiKey,$token);<br \/>\n\t}<br \/>\n\telseif ($formid==4) {<br \/>\n\t\t\/\/ Demande de rappel :<br \/>\n\t\t$name=&quot;Demande de rappel &#8211; &quot;.$posted_data[&lsquo;tel&rsquo;].&quot;\\n\\n&quot;;<br \/>\n\t\t$desc=$posted_data[&lsquo;tel&rsquo;].&quot; souhaite \u00eatre rappel\u00e9 !&quot;.&quot;\\n\\n&quot;;<br \/>\n\t\t$desc.=&quot;Affili\u00e9 :&quot;.$_COOKIE[&lsquo;from&rsquo;].&quot;\\n\\n&quot;;<br \/>\n\t\t$desc.=&quot;&#8211; Ce email a \u00e9t\u00e9 envoy\u00e9 via formulaire de contact #&quot;.$formid.&quot; de xxx &quot;.&quot;\\n\\n&quot;;<br \/>\n\t\tadd_to_trello($name,$desc,$listid,$boardid,$apiKey,$token);<br \/>\n\t}<br \/>\n}<\/p>\n<p>function add_to_trello($name,$desc,$listid,$boardid,$apiKey,$token){<br \/>\n\t$data = array(<br \/>\n\t\t&lsquo;idList&rsquo; =&gt; $listid,<br \/>\n\t\t&lsquo;name&rsquo; =&gt; $name,<br \/>\n\t\t&lsquo;desc&rsquo; =&gt; $desc<br \/>\n\t);<br \/>\n\t$card=cURL_POST_trello($data,&rsquo;https:\/\/trello.com\/1\/cards\/&rsquo;,$apiKey,$token);<br \/>\n}<\/p>\n<p>function cURL_POST_trello($data,$url,$key,$token){<br \/>\n$ch = curl_init();<br \/>\n$questionmarkishere=strpos($url,&rsquo;?&rsquo;);<br \/>\nif ($questionmarkishere){$char=&rsquo;&amp;&rsquo;;}else{$char=&rsquo;?&rsquo;;}<br \/>\ncurl_setopt($ch, CURLOPT_URL, $url.$char.&rsquo;key=&rsquo;.$key.&rsquo;&amp;token=&rsquo;.$token);<br \/>\ncurl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);<br \/>\ncurl_setopt($ch, CURLOPT_POST, true);<br \/>\ncurl_setopt($ch, CURLOPT_POSTFIELDS, $data);<br \/>\ncurl_setopt($ch, CURLOPT_HEADER, false);<br \/>\n$body = curl_exec($ch);<br \/>\n$headers = curl_getinfo($ch);<br \/>\n\/\/$result=array(&lsquo;headers&rsquo;=&gt;$headers,&rsquo;body&rsquo;=&gt;$body);<br \/>\ncurl_close($ch);<br \/>\n$result=json_decode($body);<br \/>\nreturn $result;<br \/>\n}<br \/>\n[\/php]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The idea is to add a trello card to your trello board anytime you receive an email from your contact form 7 wordpress plugin. Here is how you can do it : [php light=\u00a0\u00bbtrue\u00a0\u00bb] add_action( &lsquo;wpcf7_mail_sent&rsquo;, &lsquo;your_wpcf7_mail_sent_function&rsquo; ); function your_wpcf7_mail_sent_function($contact_form){ $boardid=&rsquo;5040f5a3********d1c9ddc70&prime;; $listid=&rsquo;507f1*********a7a4885&prime;; $apiKey=&rsquo;6b93***********9146d740c2555798d8&prime;; $token=&rsquo;6a50b26d45736cfc***********91a29b9bfc7a8c&rsquo;; $posted_data = $contact_form-&gt;posted_data; $formid=$contact_form-&gt;id; if ($formid==2){ \/\/ devis d\u00e9taill\u00e9 : $name=&quot;Demande [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"enabled":false},"version":2}},"categories":[2,7],"tags":[],"class_list":["post-2164","post","type-post","status-publish","format-standard","hentry","category-dev","category-web"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/rationalk.ch\/blog\/wp-json\/wp\/v2\/posts\/2164","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/rationalk.ch\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/rationalk.ch\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/rationalk.ch\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/rationalk.ch\/blog\/wp-json\/wp\/v2\/comments?post=2164"}],"version-history":[{"count":0,"href":"https:\/\/rationalk.ch\/blog\/wp-json\/wp\/v2\/posts\/2164\/revisions"}],"wp:attachment":[{"href":"https:\/\/rationalk.ch\/blog\/wp-json\/wp\/v2\/media?parent=2164"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/rationalk.ch\/blog\/wp-json\/wp\/v2\/categories?post=2164"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/rationalk.ch\/blog\/wp-json\/wp\/v2\/tags?post=2164"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}