Advertisement
Guest User

Untitled

a guest
Dec 14th, 2017
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.75 KB | None | 0 0
  1.  
  2. function mailtrap($phpmailer) {
  3.     $phpmailer->isSMTP();
  4.     $phpmailer->Host = 'smtp.mailtrap.io';
  5.     $phpmailer->SMTPAuth = true;
  6.     $phpmailer->Port = 2525;
  7.     $phpmailer->Username = '18bbd30e953f63';
  8.     $phpmailer->Password = 'df157129a86998';
  9. }
  10.  
  11. add_action('phpmailer_init', 'mailtrap');
  12.  
  13.     /*
  14.         Enviando contato para a gestão de Leads do Eleve Crm
  15.     */
  16.     add_action('wpcf7_before_send_mail', 'wpcf7_to_web_service');
  17.     function wpcf7_to_web_service ($WPCF7_ContactForm) {
  18.  
  19.         $submission = WPCF7_Submission::get_instance();
  20.  
  21.         $posted_data =& $submission->get_posted_data();
  22.  
  23.         if(!empty($posted_data))
  24.         {
  25.             $api_url = 'http://localhost/eleve/crm/api/1.0/leads';
  26.             $data_contato['token_conta']   = '6ec23dad0d30abd';
  27.             $data_contato['nome_lead']     = $posted_data['nome'];
  28.             $data_contato['email_lead']    = $posted_data['email'];
  29.  
  30.             if (isset($posted_data['form_planos']) && $posted_data['form_planos'] == 1)
  31.             {
  32.                 $data_contato['telefone_lead'] = $posted_data['telefone'];
  33.                 $data_contato['origem_lead']   = 'planos-site-optcon-rh';
  34.  
  35.                 $empresa = array(
  36.                     'campo'      => 'Empresa',
  37.                     'campo_slug' => 'empresa',
  38.                     'valor'      => $posted_data['empresa']
  39.                 );
  40.  
  41.                 $assunto  = array(
  42.                     'campo'      => 'Assunto',
  43.                     'campo_slug' => 'assunto',
  44.                     'valor'      => $posted_data['assunto']
  45.                 );
  46.  
  47.                 $data_contato['custom']  = array($empresa, $assunto);
  48.              } else if (isset($posted_data['form_contato']) && $posted_data['form_contato'] == 1)
  49.              {
  50.                 $data_contato['origem_lead']   = 'contato-site-optcon-rh';
  51.  
  52.                 $assunto  = array(
  53.                     'campo'      => 'Assunto',
  54.                     'campo_slug' => 'assunto',
  55.                     'valor'      => $posted_data['assunto']
  56.                 );
  57.  
  58.                 $mensagem = array(
  59.                     'campo'      => 'Mensagem',
  60.                     'campo_slug' => 'mensagem',
  61.                     'valor'      => $posted_data['mensagem']
  62.                 );
  63.              }
  64.  
  65.                $args = array(
  66.                     'body' => $data_contato,
  67.                     'timeout' => '5',
  68.                     'redirection' => '5',
  69.                     'httpversion' => '1.0',
  70.                     'blocking' => true,
  71.                     'headers' => array('Content-Type: application/json'),
  72.                     'cookies' => array()
  73.                 );
  74.  
  75.                 $response = wp_remote_post( $api_url, $args );
  76.  
  77.         }
  78.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement