36 lines
929 B
PHP
36 lines
929 B
PHP
<?php
|
|
|
|
go_form_admin_action('export_opengoth');
|
|
if (!isset($_POST['value_one'])) {
|
|
wp_redirect(admin_url('admin.php?page=go-form-settings'));
|
|
exit;
|
|
}
|
|
|
|
$form_id = intval($_POST['value_one']);
|
|
$form = go_form_get_form_by_id($form_id);
|
|
$form_name = $form ? $form->name : 'Unknown Form';
|
|
$entries = go_form_get_entries($form_id);
|
|
|
|
header('Content-Type: text/json; charset=utf-8');
|
|
header('Content-Disposition: attachment; filename="go-form-' . sanitize_title($form_name) . '-export.csv"');
|
|
|
|
$output = fopen('php://output', 'w');
|
|
fputcsv($output, ['ID', 'First Name', 'Last Name', 'Country', 'Club', 'Rank', 'Email', 'EGD Number', 'Comment', 'Date Added']);
|
|
|
|
foreach ($entries as $e) {
|
|
global $ranks;
|
|
fputcsv($output, [
|
|
$e->id,
|
|
$e->first_name,
|
|
$e->last_name,
|
|
$e->country,
|
|
$e->club,
|
|
$ranks[$e->rank] ?? '',
|
|
$e->email,
|
|
$e->egd_number,
|
|
$e->comment,
|
|
$e->created_at
|
|
]);
|
|
}
|
|
|
|
fclose($output); |