Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function mailtrap($phpmailer) {
- $phpmailer->isSMTP();
- $phpmailer->Host = 'smtp.mailtrap.io';
- $phpmailer->SMTPAuth = true;
- $phpmailer->Port = 2525;
- $phpmailer->Username = '18bbd30e953f63';
- $phpmailer->Password = 'df157129a86998';
- }
- add_action('phpmailer_init', 'mailtrap');
- /*
- Enviando contato para a gestão de Leads do Eleve Crm
- */
- add_action('wpcf7_before_send_mail', 'wpcf7_to_web_service');
- function wpcf7_to_web_service ($WPCF7_ContactForm) {
- $submission = WPCF7_Submission::get_instance();
- $posted_data =& $submission->get_posted_data();
- if(!empty($posted_data))
- {
- $api_url = 'http://localhost/eleve/crm/api/1.0/leads';
- $data_contato['token_conta'] = '6ec23dad0d30abd';
- $data_contato['nome_lead'] = $posted_data['nome'];
- $data_contato['email_lead'] = $posted_data['email'];
- if (isset($posted_data['form_planos']) && $posted_data['form_planos'] == 1)
- {
- $data_contato['telefone_lead'] = $posted_data['telefone'];
- $data_contato['origem_lead'] = 'planos-site-optcon-rh';
- $empresa = array(
- 'campo' => 'Empresa',
- 'campo_slug' => 'empresa',
- 'valor' => $posted_data['empresa']
- );
- $assunto = array(
- 'campo' => 'Assunto',
- 'campo_slug' => 'assunto',
- 'valor' => $posted_data['assunto']
- );
- $data_contato['custom'] = array($empresa, $assunto);
- } else if (isset($posted_data['form_contato']) && $posted_data['form_contato'] == 1)
- {
- $data_contato['origem_lead'] = 'contato-site-optcon-rh';
- $assunto = array(
- 'campo' => 'Assunto',
- 'campo_slug' => 'assunto',
- 'valor' => $posted_data['assunto']
- );
- $mensagem = array(
- 'campo' => 'Mensagem',
- 'campo_slug' => 'mensagem',
- 'valor' => $posted_data['mensagem']
- );
- }
- $args = array(
- 'body' => $data_contato,
- 'timeout' => '5',
- 'redirection' => '5',
- 'httpversion' => '1.0',
- 'blocking' => true,
- 'headers' => array('Content-Type: application/json'),
- 'cookies' => array()
- );
- $response = wp_remote_post( $api_url, $args );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement