Skip to content

Instantly share code, notes, and snippets.

@siffring
Created July 17, 2012 15:16
Show Gist options
  • Save siffring/3130009 to your computer and use it in GitHub Desktop.
Save siffring/3130009 to your computer and use it in GitHub Desktop.
Export ExpressionEngine members to CSV
<?php
header('Content-Type: application/csv');
header('Content-Disposition: attachment; filename=member_export.csv');
header('Pragma: no-cache');
?>
{!--
Exports the EE members in CSV format. This is only accessible to admins and editors.
Does not export members in the banned or guests groups.
--}
{exp:ajw_export
sql="SELECT exp_members.member_id AS member_id, exp_member_groups.group_title AS 'group', screen_name, email, m_field_id_3 AS first_name, m_field_id_4 AS last_name, m_field_id_1 AS title, m_field_id_2 AS facility, m_field_id_7 AS region, m_field_id_5 AS other_medical_device_company, m_field_id_6 AS percentage_time_other_company, m_field_id_8 AS import_flag, m_field_id_9 AS admin_notes, FROM_UNIXTIME(join_date) AS join_date FROM exp_members, exp_member_data, exp_member_groups WHERE exp_member_data.member_id = exp_members.member_id AND exp_members.group_id = exp_member_groups.group_id AND exp_members.group_id NOT IN (2,3)"
format="csv"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment