# In /includes/reports/export-csv.php replace everything from around line 238 and below with this code
//Export
$select = 'SELECT name, email, custom_fields FROM '.$table.' where id IN ('.$subscribers.') '.$additional_query;
$export = mysqli_query($mysqli, $select);
$fields = mysqli_num_fields ( $export );
$data = '';
header('Content-Type: text/csv');
header('Content-Disposition: attachment; filename="' . $filename . '"');
header("Pragma: no-cache");
header("Expires: 0");
$out = fopen('php://output', 'w');
while( $row = mysqli_fetch_row( $export ) )
{
$line = '';
$i = 1;
if (isset($row[2]) && $row[2]):
$customFields = explode('%s%', $row[2]);
unset($row[2]);
$row = array_values($row);
foreach ($customFields as $field):
$row[] = $field;
endforeach;
$fields = count($row);
endif;
fputcsv($out, $row);
}
if ( $data == "" )
{
$data = "\n(0) Records Found!\n";
}
fclose($out);
PHP Update Sendy Export to Include Custom Fields
Older versions of Sendy do not include custom fields in their exports. This script adds those fields to the CSV exports.
Snippet Viewed 3740 times.
Share your PHP code snippets:
- Get some recognition & link back to your site.
Related Articles