bridge parameter name // static — fixed values always sent with this form (not from user input) // // The 'handler' value must match a case in bridge-receive.php's router. // $epn_bridge_forms = [ // ── SRC Webinar Registration (CF7 form 38441) ──────────────────────── 38441 => [ 'handler' => 'webinar', 'fields' => [ 'your-first-name' => 'firstname', 'your-last-name' => 'lastname', 'your-email' => 'email', 'your-org' => 'organization', 'job-title' => 'jobtitle', 'org-type' => 'orgcategory', ], 'static' => [ 'form_type' => 'src', 'webinar_event' => 'sustaining-rebuilding-resilient-communities', ], ], // ── CSRI Webinar Registration (CF7 form 38453) ────────────────────── 38453 => [ 'handler' => 'webinar', 'fields' => [ 'firstname' => 'firstname', 'lastname' => 'lastname', 'email' => 'email', 'organization' => 'organization', 'jobtitle' => 'jobtitle', 'orgcategory' => 'orgcategory', 'current_govt_employee'=> 'current_govt_employee', 'current_agency' => 'current_agency', 'former_civil_servant' => 'former_civil_servant', 'former_agency' => 'former_agency', 'csri_topics' => 'csri_topics', 'eia' => 'eia', 'ffog' => 'ffog', ], 'static' => [ 'form_type' => 'csri', 'webinar_event' => 'civil-service-resilience', ], ], // ── CSR Newsletter Subscription (CF7 form 37936) ──────────────────── 37936 => [ 'handler' => 'newsletter', 'fields' => [ 'your-first-name' => 'first_name', 'your-last-name' => 'last_name', 'your-email' => 'email', 'eia' => 'eia', 'ffog' => 'ffog', ], 'static' => [ 'csr' => '1', ], ], // ── EPN Newsletter Subscription (CF7 form 4601) ───────────────────── 4601 => [ 'handler' => 'newsletter', 'fields' => [ 'your-first-name' => 'first_name', 'your-last-name' => 'last_name', 'your-email' => 'email', 'subscription_type' => 'subscription_type', ], 'static' => [], ], // ── Volunteer Recruitment (CF7 form 94) ──────────────────────────── 94 => [ 'handler' => 'vrm', 'fields' => [ 'your-first-name' => 'first_name', 'your-last-name' => 'last_name', 'your-email' => 'email', 'phone-number' => 'phone', 'your-message' => 'comments', ], 'static' => [], ], // ── Job Ads Request (CF7 form 38574) ───────────────────────────────── // Form URL: /federal-employee-resources/job-board/ad-request/ // Thank-you redirect: /federal-employee-resources/job-board/ad-request/thank-you 38574 => [ 'handler' => 'jarm', 'fields' => [ 'your-first-name' => 'first_name', 'your-last-name' => 'last_name', 'your-email' => 'email', 'your-phone' => 'phone', 'organization-name' => 'organization_name', 'organization-type' => 'organization_type', 'job-title' => 'job_title', 'job-summary' => 'job_summary', 'commitment' => 'commitment', 'location-type' => 'location_type', 'city' => 'city', 'state' => 'state', 'closing-date' => 'closing_date', 'job-url' => 'job_url', 'job-classification' => 'job_classification', ], 'static' => [], ], // ── Future forms go here ───────────────────────────────────────────── // To add a new form, add its config here. // The 'handler' must match a case in bridge-receive.php on the system site. ]; // ────────────────────────────────────────────── // CF7 HOOKS // ────────────────────────────────────────────── /** * Skip default CF7 email for forms managed by this plugin. */ add_action('wpcf7_before_send_mail', 'epn_bridge_skip_mail'); function epn_bridge_skip_mail($contact_form) { global $epn_bridge_forms; $form_id = (int) $contact_form->id(); if ( !empty($epn_bridge_forms) && isset($epn_bridge_forms[$form_id]) ) { $contact_form->skip_mail = true; } return $contact_form; } /** * Forward CF7 submissions to the system site via bridge-receive.php. * * Reads the $epn_bridge_forms config, maps CF7 field names to system-side * parameter names, merges static params, and POSTs the payload. * To add a new form, add a config entry above — no code changes needed. */ add_action('wpcf7_before_send_mail', 'epn_bridge_forward', 20); function epn_bridge_forward($contact_form) { global $epn_bridge_forms; $form_id = (int) $contact_form->id(); // Only process forms in the config if ( empty($epn_bridge_forms) || !isset($epn_bridge_forms[$form_id]) ) { return $contact_form; } if ( !class_exists('WPCF7_Submission') ) { return $contact_form; } $submission = WPCF7_Submission::get_instance(); if ( !$submission ) { return $contact_form; } $config = $epn_bridge_forms[$form_id]; $posted = $submission->get_posted_data(); // ── Build the payload ───────────────────────────────────────────────── $payload = [ 'bridge_secret' => EPN_BRIDGE_SECRET, 'handler' => $config['handler'], ]; // Map CF7 fields → bridge parameter names foreach ( $config['fields'] as $cf7_tag => $bridge_param ) { $value = isset($posted[$cf7_tag]) ? $posted[$cf7_tag] : ''; if ( is_array($value) ) { $value = implode(', ', $value); } $payload[$bridge_param] = $value; } // Add static parameters if ( !empty($config['static']) ) { foreach ( $config['static'] as $key => $val ) { $payload[$key] = $val; } } // ── Send to system site ─────────────────────────────────────────────── $url = EPN_SYSTEM_URL . '/bridge-receive.php'; // Temporary debug logging $debug_payload = $payload; unset($debug_payload['bridge_secret']); error_log('[EPN Bridge] Sending form ' . $form_id . ' to ' . $url . ' payload=' . wp_json_encode($debug_payload)); $response = wp_remote_post($url, [ 'timeout' => 30, 'sslverify' => true, 'body' => $payload, ]); if ( is_wp_error($response) ) { error_log('[EPN Bridge] Failed to forward form ' . $form_id . ': ' . $response->get_error_message()); } else { $code = wp_remote_retrieve_response_code($response); $body = wp_remote_retrieve_body($response); error_log('[EPN Bridge] Form ' . $form_id . ' response HTTP ' . $code . ': ' . $body); } return $contact_form; } // ────────────────────────────────────────────── // CLOUDFLARE TURNSTILE — SPAM PROTECTION // ────────────────────────────────────────────── /** * Inject Turnstile widget into CF7 forms managed by this plugin. * Adds the widget just before the submit button. */ add_filter('wpcf7_form_elements', 'epn_bridge_inject_turnstile'); function epn_bridge_inject_turnstile($content) { global $epn_bridge_forms; $cf = wpcf7_get_current_contact_form(); if ( !$cf ) return $content; $form_id = (int) $cf->id(); if ( empty($epn_bridge_forms) || !isset($epn_bridge_forms[$form_id]) ) return $content; $site_key = defined('EPN_TURNSTILE_SITE_KEY') ? EPN_TURNSTILE_SITE_KEY : ''; if ( $site_key === '' ) return $content; $widget = '
'; // Insert before the first submit button $content = preg_replace('/(]*type=["\']submit["\'][^>]*>)/i', $widget . '$1', $content, 1); return $content; } /** * Load the Turnstile API script on pages with our CF7 forms. */ add_action('wp_enqueue_scripts', 'epn_bridge_enqueue_turnstile'); function epn_bridge_enqueue_turnstile() { global $post, $epn_bridge_forms; if ( !is_a($post, 'WP_Post') || !has_shortcode($post->post_content, 'contact-form-7') ) return; // Check if any of our form IDs appear in the page $dominated = false; if ( !empty($epn_bridge_forms) ) { foreach ( $epn_bridge_forms as $fid => $cfg ) { if ( strpos($post->post_content, (string) $fid) !== false ) { $dominated = true; break; } } } // Also check hash IDs (CF7 5.9+) if ( !$dominated ) { $hash_ids = ['403dffc', 'a0d2db1', '1245bfe', 'b110a4b', '2997788']; // CSRI Webinar + VRM + CSR Newsletter + SRC + JARM foreach ( $hash_ids as $hid ) { if ( strpos($post->post_content, $hid) !== false ) { $dominated = true; break; } } } if ( $dominated ) { wp_enqueue_script('cf-turnstile', 'https://challenges.cloudflare.com/turnstile/v0/api.js', [], null, true); } // Flatpickr for JARM date picker if ( strpos($post->post_content, '2997788') !== false || strpos($post->post_content, '38574') !== false ) { wp_enqueue_script('flatpickr', 'https://cdn.jsdelivr.net/npm/flatpickr', [], null, true); } } /** * Validate Turnstile token server-side before CF7 processes the form. * If validation fails, mark as spam. */ add_filter('wpcf7_spam', 'epn_bridge_turnstile_validate', 10, 2); function epn_bridge_turnstile_validate($spam, $submission) { if ( $spam ) return $spam; // already flagged global $epn_bridge_forms; $cf = wpcf7_get_current_contact_form(); if ( !$cf ) return $spam; $form_id = (int) $cf->id(); if ( empty($epn_bridge_forms) || !isset($epn_bridge_forms[$form_id]) ) return $spam; $secret = defined('EPN_TURNSTILE_SECRET_KEY') ? EPN_TURNSTILE_SECRET_KEY : ''; if ( $secret === '' ) return $spam; $token = isset($_POST['cf-turnstile-response']) ? sanitize_text_field($_POST['cf-turnstile-response']) : ''; if ( $token === '' ) { $spam = true; return $spam; } $response = wp_remote_post('https://challenges.cloudflare.com/turnstile/v0/siteverify', [ 'body' => [ 'secret' => $secret, 'response' => $token, 'remoteip' => isset($_SERVER['HTTP_CF_CONNECTING_IP']) ? $_SERVER['HTTP_CF_CONNECTING_IP'] : $_SERVER['REMOTE_ADDR'], ], 'timeout' => 10, ]); if ( is_wp_error($response) ) return $spam; // fail open on network error $body = json_decode(wp_remote_retrieve_body($response), true); if ( empty($body['success']) ) { $spam = true; } return $spam; } // ────────────────────────────────────────────── // CSRI FORM — CONDITIONAL FIELD VISIBILITY // ────────────────────────────────────────────── // // Hides "Current agency" / "Former agency" text fields until the // corresponding radio button is set to "yes". Only loads on pages // that contain CF7 form 38453. add_action('wp_footer', 'epn_bridge_csri_conditional_js'); function epn_bridge_csri_conditional_js() { global $post; if ( !is_a($post, 'WP_Post') || !has_shortcode($post->post_content, 'contact-form-7') ) { return; } // CF7 shortcodes may use numeric ID (38453) or hash ID (403dffc) if ( strpos($post->post_content, '38453') === false && strpos($post->post_content, '403dffc') === false ) { return; } ?> post_content, 'contact-form-7') ) return; if ( strpos($post->post_content, '2997788') === false && strpos($post->post_content, '38574') === false ) return; ?> post_content, 'contact-form-7') ) return; if ( strpos($post->post_content, '2997788') === false && strpos($post->post_content, '38574') === false ) return; ?> 15, 'sslverify' => true, ]); if (is_wp_error($response)) { return '

Unable to load job listings at this time. Please try again later.

'; } $code = wp_remote_retrieve_response_code($response); if ($code < 200 || $code >= 300) { return '

Unable to load job listings at this time. Please try again later.

'; } $body = wp_remote_retrieve_body($response); $jobs = json_decode($body, true); if (!is_array($jobs)) { $jobs = []; } set_transient($cache_key, $jobs, $cache_ttl); } if (empty($jobs)) { return '

No job ads are currently posted. Please check back soon.

'; } // Find the latest published_date for the "Last Updated" badge $latest_date = ''; foreach ($jobs as $job) { if (!empty($job['published_date']) && $job['published_date'] > $latest_date) { $latest_date = $job['published_date']; } } // Build filter options from job data $locations = []; $states = []; $classifications = []; foreach ($jobs as $job) { if (!empty($job['location_label'])) $locations[$job['location_type']] = $job['location_label']; if (!empty($job['state'])) $states[$job['state']] = $job['state']; if (!empty($job['classification_label'])) $classifications[$job['job_classification']] = $job['classification_label']; } ksort($states); asort($classifications); ob_start(); ?>
Jobs Listed Last Updated:
Read more ›