function uba_process_captacao_pro_function() { if (!empty($_POST['uba_honeypot'])) wp_send_json_error('Requisição bloqueada.'); $nome = sanitize_text_field($_POST['nome']); $email = sanitize_email($_POST['email']); $telefone = sanitize_text_field($_POST['telefone']); $documento = sanitize_text_field($_POST['documento']); $empresa = sanitize_text_field($_POST['empresa']); $faturamento = sanitize_text_field($_POST['faturamento']); $servico = sanitize_text_field($_POST['servico']); $briefing = sanitize_textarea_field($_POST['briefing']); $utm_source = sanitize_text_field($_POST['utm_source']); $utm_medium = sanitize_text_field($_POST['utm_medium']); $utm_campaign = sanitize_text_field($_POST['utm_campaign']); $utm_term = sanitize_text_field($_POST['utm_term']); $domain = substr(strrchr($email, "@"), 1); $blocked_domains = array('yopmail.com', 'tempmail.com', 'mailinator.com', '10minutemail.com', 'guerrillamail.com'); if (in_array(strtolower($domain), $blocked_domains)) { wp_send_json_error('Domínio de e-mail não permitido. Use seu e-mail corporativo ou pessoal real.'); } $doc_limpo = preg_replace('/[^0-9]/', '', $documento); if (strlen($doc_limpo) != 14) { wp_send_json_error('O CNPJ informado possui o tamanho incorreto. Verifique os dados.'); } // TRAVA ANTI-DUPLICIDADE B2B $args = array( 'post_type' => 'uba_lead', 'meta_query' => array( array('key' => 'email', 'value' => $email) ), 'date_query' => array( array('after' => '5 minutes ago') ), 'fields' => 'ids' ); $duplicates = new WP_Query($args); if ($duplicates->found_posts > 0) { wp_send_json_success('Proposta já enviada com sucesso!'); } // 1. SALVA NO CPT DO WORDPRESS $post_id = wp_insert_post(array( 'post_title' => $nome . ' - ' . $empresa, 'post_type' => 'uba_lead', 'post_status' => 'publish' )); if ($post_id) { update_post_meta($post_id, 'tipo_form', 'Captação B2B'); update_post_meta($post_id, 'nome', $nome); update_post_meta($post_id, 'email', $email); update_post_meta($post_id, 'whatsapp', $telefone); update_post_meta($post_id, 'documento', $documento); update_post_meta($post_id, 'empresa', $empresa); update_post_meta($post_id, 'faturamento', $faturamento); update_post_meta($post_id, 'servico', $servico); update_post_meta($post_id, 'briefing', $briefing); update_post_meta($post_id, 'utm_source', $utm_source); update_post_meta($post_id, 'utm_medium', $utm_medium); update_post_meta($post_id, 'utm_campaign', $utm_campaign); update_post_meta($post_id, 'utm_term', $utm_term); } // 2. DISPARO PARA A EDGE FUNCTION $webhook_edge = 'https://svjaoxfwelhqokgscrpe.supabase.co/functions/v1/processar-leads'; $secret_token = 'UbaTech_2026_!@TokenSuperSeguro998877'; $webhook_data = array( 'tipo_form' => 'Captação Geral B2B', 'nome' => $nome, 'email' => $email, 'whatsapp' => $telefone, 'documento' => $documento, 'empresa' => $empresa, 'faturamento' => $faturamento, 'servico' => $servico, 'briefing' => $briefing, 'utm_source' => $utm_source, 'utm_medium' => $utm_medium, 'utm_campaign'=> $utm_campaign, 'utm_term' => $utm_term, 'data_hora' => date('Y-m-d H:i:s') ); $webhook_args = array( 'body' => wp_json_encode($webhook_data), 'headers' => array('Content-Type' => 'application/json', 'Authorization' => 'Bearer ' . $secret_token), 'timeout' => 5, 'blocking' => false ); wp_remote_post($webhook_edge, $webhook_args); wp_send_json_success('Proposta enviada com sucesso! Nossos especialistas farão contato.'); } add_action('wp_ajax_uba_process_captacao_pro', 'uba_process_captacao_pro_function'); add_action('wp_ajax_nopriv_uba_process_captacao_pro', 'uba_process_captacao_pro_function'); https://agenciauba.com.br/post-sitemap.xml 2026-02-06T02:00:23+00:00 https://agenciauba.com.br/page-sitemap.xml 2026-03-04T18:50:56+00:00