| @@ -404,8 +404,9 @@ | ||
| 404 | 404 | if ($form['title'] == sanitize_text_field($data['form_title'])) { |
| 405 | 405 | if (isset($form['email'])) { |
| 406 | 406 | $email_enabled = $form['email'] == 1; |
| 407 | 407 | } |
| 408 | + $per_action_emails = isset($form['email_addresses']) ? trim($form['email_addresses']) : ''; | |
| 408 | 409 | break; |
| 409 | 410 | } |
| 410 | 411 | } |
| 411 | 412 | } |
| @@ -410,9 +411,14 @@ | ||
| 410 | 411 | } |
| 411 | 412 | } |
| 412 | 413 | |
| 413 | 414 | if ($email_enabled) { |
| 414 | - $to = get_option('admin_email'); | |
| 415 | + if (!empty($per_action_emails)) { | |
| 416 | + $to = array_map('trim', explode(',', $per_action_emails)); | |
| 417 | + } else { | |
| 418 | + $default = get_option('qlcd_wp_chatbot_admin_email', ''); | |
| 419 | + $to = !empty($default) ? array_map('trim', explode(',', $default)) : get_option('admin_email'); | |
| 420 | + } | |
| 415 | 421 | $subject = sanitize_text_field($data['form_title']) . " - " . esc_html__('New AI Chat Submission', 'chatbot'); |
| 416 | 422 | $headers = array('Content-Type: text/html; charset=UTF-8'); |
| 417 | 423 | if (!empty($reply_to)) { |
| 418 | 424 | $headers[] = 'Reply-To: ' . $reply_to; |