add_action('wpcf7_mail_sent', 'cf7_send_to_telegram_with_static_image'); function cf7_send_to_telegram_with_static_image($contact_form) { $submission = WPCF7_Submission::get_instance(); if (!$submission) { // Нет отправки формы — выходим, чтобы не было ошибок return; } $data = $submission->get_posted_data(); if (!$data || !is_array($data)) { return; } // Безопасно получаем поля, если их нет — ставим пустую строку $name = isset($data['your-name']) ? sanitize_text_field($data['your-name']) : ''; $email = isset($data['your-email']) ? sanitize_email($data['your-email']) : ''; $order_id = isset($data['your-order-id']) ? sanitize_text_field($data['your-order-id']) : ''; $category = isset($data['your-category']) ? sanitize_text_field($data['your-category']) : ''; $message = isset($data['your-message']) ? sanitize_textarea_field($data['your-message']) : ''; $token = '8082821430:AAGLgb78K2hx1CEfOixhZ3xEL5hCXkR0C_M'; $allowed_users = [151916075, 181993141]; $text = "🔔 *New Contact Form Submission*\n" . "━━━━━━━━━━━━━━━\n" . "👤 *Name:* $name\n" . "📧 *Email:* $email\n" . ($order_id ? "🧾 *Order ID:* $order_id\n" : "") . "📂 *Category:* $category\n" . "💬 *Message:*\n$message\n" . "━━━━━━━━━━━━━━━"; $image_url = 'https://stlmodels.com/alert.webp'; foreach ($allowed_users as $chat_id) { $send_url = "https://api.telegram.org/bot$token/sendPhoto"; $post_fields = [ 'chat_id' => $chat_id, 'photo' => $image_url, 'caption' => $text, 'parse_mode' => 'Markdown', ]; wp_remote_post($send_url, ['body' => $post_fields]); } } Cosplay | STLmodels.com

Cosplay