get_setting('subscribe_custom1_label'), 'custom2' => get_setting('subscribe_custom2_label'), 'custom3' => get_setting('subscribe_custom3_label'), ]; // CSV download if (isset($_GET['action']) && $_GET['action'] === 'csv') { verify_csrf_get(); $rows = db()->query("SELECT * FROM subscribers ORDER BY created_at DESC")->fetchAll(); header('Content-Type: text/csv; charset=UTF-8'); header('Content-Disposition: attachment; filename="subscribers-' . date('Y-m-d') . '.csv"'); $out = fopen('php://output', 'w'); // Build header row from active fields $cols = ['ID','Email','First Name','Last Name','Zip/Postal','Phone','Comments']; if ($customLabels['custom1']) $cols[] = $customLabels['custom1']; if ($customLabels['custom2']) $cols[] = $customLabels['custom2']; if ($customLabels['custom3']) $cols[] = $customLabels['custom3']; $cols[] = 'Subscribed At'; fputcsv($out, $cols); foreach ($rows as $r) { $row = [$r['id'], $r['email'], $r['first_name'], $r['last_name'], $r['zip_code'], $r['phone'], $r['comments']]; if ($customLabels['custom1']) $row[] = $r['custom1']; if ($customLabels['custom2']) $row[] = $r['custom2']; if ($customLabels['custom3']) $row[] = $r['custom3']; $row[] = $r['created_at']; fputcsv($out, $row); } fclose($out); exit; } // Delete single subscriber if ($_SERVER['REQUEST_METHOD'] === 'POST' && ($_POST['action'] ?? '') === 'delete') { verify_csrf(); $id = (int)($_POST['id'] ?? 0); if ($id) db()->prepare("DELETE FROM subscribers WHERE id = ?")->execute([$id]); flash('success', 'Subscriber deleted.'); header('Location: subscribers.php'); exit; } // Delete all if ($_SERVER['REQUEST_METHOD'] === 'POST' && ($_POST['action'] ?? '') === 'delete_all') { verify_csrf(); db()->exec("DELETE FROM subscribers"); flash('success', 'All subscribers deleted.'); header('Location: subscribers.php'); exit; } $subscribers = db()->query("SELECT * FROM subscribers ORDER BY created_at DESC")->fetchAll(); $count = count($subscribers); $optFields = subscribe_optional_fields(); $adminTitle = 'Subscribers'; include ROOT_PATH . '/admin/header.php'; ?>
✉ Subscribers ()
0): ?> ⇓ Download CSV
⚙ Configure Subscribe Fields

No subscribers yet.

# Email First Name Last Name Zip Phone Comments Subscribed