setup exporting
This commit is contained in:
36
go-form-plugin/export/mcmahon.php
Normal file
36
go-form-plugin/export/mcmahon.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
go_form_admin_action('export_mcmahon');
|
||||
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/csv; 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);
|
||||
Reference in New Issue
Block a user