Created
November 15, 2018 13:16
-
-
Save john-henry/7e34d62a30cc5b4f0038d554689fe4a1 to your computer and use it in GitHub Desktop.
JSON Member Export for ExpressionEngine
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Pass group ID as a query string | |
$group = $_GET['id']; | |
$content = array(); | |
// exclude an id like your own | |
$entries_query = $this->EE->db->query("SELECT * FROM exp_members as m LEFT JOIN exp_member_data AS d ON d.member_id = m.member_id WHERE m.group_id = '$group' and m.member_id != 4664"); | |
foreach ($entries_query->result_array() as $id => $row) { | |
$content[$id] = array(); | |
// Remove spaces from EE usernames | |
$content[$id]['username'] = str_replace(' ', '', $row['username']); | |
$parts = explode(' ', $row['screen_name']); // explode screen name | |
$name_first = array_shift($parts); | |
$name_last = array_pop($parts); | |
$name_middle = trim(implode(' ', $parts)); | |
$content[$id]['first_name'] = $name_first.' '.$name_middle; | |
$content[$id]['last_name'] = $name_last; | |
$content[$id]['email'] = $row['email']; | |
$content[$id]['join_date'] = ($row['join_date']) ? date('Y-m-d H:i:s', $row['join_date']) : ''; | |
$content[$id]['member_id'] = $row['member_id']; | |
$content[$id]['group_id'] = $row['group_id']; | |
$content[$id]['occupation'] = $row['occupation']; | |
//support fo avatars. Tailor to own situation | |
if ($row['avatar_filename'] =='default_set/avatar.jpg'){ | |
$content[$id]['avatar'] = ''; | |
}elseif($row['avatar_filename'] ==''){ | |
$content[$id]['avatar'] = ''; | |
}else { | |
$content[$id]['avatar'] = $this->EE->config->item('avatar_url').$row['avatar_filename']; | |
}; | |
// Custom profile field example | |
$content[$id]['twitter'] = $row['m_field_id_1']; | |
$content[$id]['bio'] = $row['bio']; | |
} | |
echo json_encode($content); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment