$email, 'listIds' => $list_id, 'updateEnabled' => true, ]; // Send POST request to Brevo API $response = wp_remote_post('https://api.brevo.com/v3/contacts', [ 'headers' => [ 'api-key' => $api_key, 'Content-Type' => 'application/json', 'Accept' => 'application/json', ], 'body' => json_encode($body), 'method' => 'POST', 'data_format' => 'body', ]); // Handle API response if (is_wp_error($response)) { error_log(' Brevo Error: ' . $response->get_error_message()); } else { error_log(' Brevo Response: ' . print_r($response, true)); } } // Hook into AJAX actions for logged-in and guest users add_action('wp_ajax_cubewp_submit_custom_form', 'send_custom_brevo_form_data'); add_action('wp_ajax_nopriv_cubewp_submit_custom_form', 'send_custom_brevo_form_data');