if (!defined('ABSPATH')) exit; /* ---------------------------------------- GET ALLOWED EMAILS (ACF OPTION FIELD) ---------------------------------------- */ function cr_get_allowed_emails() { $emails_raw = get_field('allowed_emails', 'option'); if (!$emails_raw) return []; $emails_array = array_map('trim', explode("\n", $emails_raw)); return array_map('strtolower', $emails_array); } function cr_is_allowed_email($email) { return in_array(strtolower($email), cr_get_allowed_emails()); } /* ---------------------------------------- EMAIL TEMPLATE ---------------------------------------- */ function cr_open_email_template($type, $email, $time, $ip) { $page = home_url('/criticalriver-open-register/'); $subject = ($type === 'approved') ? 'CriticalRiver OPEN: Approved Email Checked' : 'CriticalRiver OPEN: Unapproved Email Attempted'; $heading = ($type === 'approved') ? 'Verified Registration Request' : 'Unrecognized Email Attempt'; $body = "

$heading

"; if ($type === 'approved') { $body .= ""; } $body .= "
Email$email
Time$time
IP Address$ip
Register Page$page

Thank you,
Team CriticalRiver

"; return [$subject, $body]; } /* ---------------------------------------- CF7 Feedback Response Hook ---------------------------------------- */ add_filter('wpcf7_feedback_response', function($response, $result) { $submission = WPCF7_Submission::get_instance(); if (!$submission) return $response; $data = $submission->get_posted_data(); if (!isset($data['user_email'])) return $response; $email = sanitize_email($data['user_email']); $time = current_time('Y-m-d H:i:s'); $ip = $_SERVER['REMOTE_ADDR'] ?? ''; $admin_emails = [ 'vanitha.katta@criticalriver.com', // Add more admin emails if needed ]; $headers = ['Content-Type: text/html; charset=UTF-8']; if (cr_is_allowed_email($email)) { $status = 'approved'; list($subject, $body) = cr_open_email_template('approved', $email, $time, $ip); } else { $status = 'not_approved'; list($subject, $body) = cr_open_email_template('not_approved', $email, $time, $ip); } // Send admin email wp_mail($admin_emails, $subject, $body, $headers); // Skip default CF7 mail for this form add_filter('wpcf7_skip_mail', fn($skip, $cf) => $cf->title() === 'CriticalRiver OPEN Email Check', 10, 2); // Add status to JSON response $response['cr_open_status'] = $status; return $response; }, 10, 2); Media - CriticalRiver Media

Let’s Build Intelligent Systems Together

Empowered by our Studio Leaders, we’re enabling companies to embrace AI-first innovation. Together, we build intelligent systems that scale possibilities and performance.

Let’s start a conversation.

Tell us what you’re looking to build. Our experts are just a message away.

    Preferable Date:

    Preferable Time:

    Preferable Time Zone:

    Thank you for reaching out. Our team will connect with you shortly to discuss your requirements and next steps.