Advertisement
porquero

Integración EspoCRM y Wordpress con Contact Form 7

Jun 30th, 2022
938
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.65 KB | None
  1. <?php
  2.  
  3. // Más info: https://youtu.be/BMZcFyFPr_M
  4.  
  5. function on_submit( $form, &$abort, $submission ){ 
  6.     $data = $submission->get_posted_data();
  7.  
  8.     $url = 'MIURL';
  9.     $apiKey = 'KEY';
  10.  
  11.     $client = new EspoApiClient($url);
  12.     $client->setApiKey($apiKey);
  13.    
  14.     // Crear cotización en CRM.
  15.     try {
  16.         $response = $client->request('POST', 'Lead', [
  17.             'firstName' => $data['your-name'],
  18.             'emailAddress' => $data['your-email'],
  19.             'description' => $data['your-subject'] . ': ' . $data['your-message'],
  20.             'source' => 'Web Site',
  21.         ]);
  22.     } catch (\Exception $e) {
  23.         $errorCode = $e->getCode();
  24.     }
  25. }
  26.  
  27. add_action('wpcf7_before_send_mail', 'on_submit', 10, 3);
Advertisement
RAW Paste Data Copied
Advertisement