Version Description
Download this release
Release Info
Developer | qlstudio |
Plugin | Export User Data |
Version | 0.5.1 |
Comparing to | |
See all releases |
Version 0.5.1
- export-user-data.php +553 -0
- languages/default.mo +0 -0
- languages/default.po +82 -0
- readme.txt +68 -0
- screenshot-1.png +0 -0
export-user-data.php
ADDED
@@ -0,0 +1,553 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @package Export_User_Data
|
4 |
+
* @version 0.5
|
5 |
+
*/
|
6 |
+
/*
|
7 |
+
Plugin Name: Export User Data
|
8 |
+
Plugin URI: http://qstudio.us/plugins/
|
9 |
+
Description: Export User data, metadata and BuddyPressX Profile data.
|
10 |
+
Version: 0.5.1
|
11 |
+
Author: Q Studio
|
12 |
+
Author URI: http://qstudio.us/
|
13 |
+
License: GPL2
|
14 |
+
Text Domain: export-user-data
|
15 |
+
Source: Export User to CSV by PubPoet ( http://pubpoet.com/ )- Thanks!
|
16 |
+
*/
|
17 |
+
/* Copyright 2011 Ulrich Sossou (http://github.com/sorich87)
|
18 |
+
|
19 |
+
This program is free software; you can redistribute it and/or modify
|
20 |
+
it under the terms of the GNU General Public License, version 2, as
|
21 |
+
published by the Free Software Foundation.
|
22 |
+
|
23 |
+
This program is distributed in the hope that it will be useful,
|
24 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
25 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
26 |
+
GNU General Public License for more details.
|
27 |
+
|
28 |
+
You should have received a copy of the GNU General Public License
|
29 |
+
along with this program; if not, write to the Free Software
|
30 |
+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
31 |
+
*/
|
32 |
+
|
33 |
+
load_plugin_textdomain( 'export-user-data', false, basename( dirname( __FILE__ ) ) . '/languages' );
|
34 |
+
|
35 |
+
/**
|
36 |
+
* Main plugin class
|
37 |
+
*
|
38 |
+
* @since 0.1
|
39 |
+
**/
|
40 |
+
class Q_EUD_Export_Users {
|
41 |
+
|
42 |
+
/**
|
43 |
+
* Class contructor
|
44 |
+
*
|
45 |
+
* @since 0.1
|
46 |
+
**/
|
47 |
+
public function __construct() {
|
48 |
+
add_action( 'admin_menu', array( $this, 'add_admin_pages' ) );
|
49 |
+
add_action( 'init', array( $this, 'generate_data' ) );
|
50 |
+
add_filter( 'q_eud_exclude_data', array( $this, 'exclude_data' ) );
|
51 |
+
}
|
52 |
+
|
53 |
+
/**
|
54 |
+
* Add administration menus
|
55 |
+
*
|
56 |
+
* @since 0.1
|
57 |
+
**/
|
58 |
+
public function add_admin_pages() {
|
59 |
+
add_users_page( __( 'Export User Data', 'export-user-data' ), __( 'Export User Data', 'export-user-data' ), 'list_users', 'export-user-data', array( $this, 'users_page' ) );
|
60 |
+
}
|
61 |
+
|
62 |
+
/* clean that stuff up ## */
|
63 |
+
public function sanitize($value) {
|
64 |
+
$value = str_replace("\r", '', $value);
|
65 |
+
$value = str_replace("\n", '', $value);
|
66 |
+
$value = str_replace("\t", '', $value);
|
67 |
+
return $value;
|
68 |
+
}
|
69 |
+
|
70 |
+
/**
|
71 |
+
* Process content of CSV file
|
72 |
+
*
|
73 |
+
* @since 0.1
|
74 |
+
**/
|
75 |
+
public function generate_data() {
|
76 |
+
if ( isset( $_POST['_wpnonce-q-eud-export-user-page_export'] ) ) {
|
77 |
+
check_admin_referer( 'q-eud-export-user-page_export', '_wpnonce-q-eud-export-user-page_export' );
|
78 |
+
|
79 |
+
// build argument array ##
|
80 |
+
$args = array(
|
81 |
+
'fields' => 'all_with_meta',
|
82 |
+
'role' => stripslashes( $_POST['role'] )
|
83 |
+
);
|
84 |
+
|
85 |
+
// did the user request a specific program ? ##
|
86 |
+
if ( isset( $_POST['program'] ) && $_POST['program'] != '' ) {
|
87 |
+
|
88 |
+
$args['meta_key'] = 'member_of_club';
|
89 |
+
$args['meta_value'] = (int)$_POST['program'];
|
90 |
+
$args['meta_compare'] = '=';
|
91 |
+
|
92 |
+
}
|
93 |
+
|
94 |
+
add_action( 'pre_user_query', array( $this, 'pre_user_query' ) );
|
95 |
+
$users = get_users( $args );
|
96 |
+
remove_action( 'pre_user_query', array( $this, 'pre_user_query' ) );
|
97 |
+
|
98 |
+
if ( ! $users ) {
|
99 |
+
$referer = add_query_arg( 'error', 'empty', wp_get_referer() );
|
100 |
+
wp_redirect( $referer );
|
101 |
+
exit;
|
102 |
+
}
|
103 |
+
|
104 |
+
$sitename = sanitize_key( get_bloginfo( 'name' ) );
|
105 |
+
if ( ! empty( $sitename ) )
|
106 |
+
$sitename .= '.';
|
107 |
+
|
108 |
+
// export method ? ##
|
109 |
+
$export_method = 'excel'; // default to Excel export ##
|
110 |
+
if ( isset( $_POST['format'] ) && $_POST['format'] != '' ) {
|
111 |
+
|
112 |
+
$export_method = $_POST['format'];
|
113 |
+
|
114 |
+
}
|
115 |
+
|
116 |
+
// set export filename structure ##
|
117 |
+
$filename = $sitename . 'users.' . date( 'Y-m-d-H-i-s' );
|
118 |
+
|
119 |
+
switch ( $export_method ) {
|
120 |
+
|
121 |
+
case "csv":
|
122 |
+
|
123 |
+
// to csv ##
|
124 |
+
header( 'Content-Description: File Transfer' );
|
125 |
+
header( 'Content-Disposition: attachment; filename='.$filename.'.csv' );
|
126 |
+
header( 'Content-Type: text/csv; charset=' . get_option( 'blog_charset' ), true );
|
127 |
+
|
128 |
+
// how to seperate data ##
|
129 |
+
$seperator = ','; // comma for csv ##
|
130 |
+
|
131 |
+
break;
|
132 |
+
|
133 |
+
case ('excel'):
|
134 |
+
|
135 |
+
// to xls ##
|
136 |
+
header( 'Content-Description: File Transfer' );
|
137 |
+
header("Content-Type: application/vnd.ms-excel");
|
138 |
+
header("Content-Disposition: attachment; filename=$filename.xls");
|
139 |
+
header("Pragma: no-cache");
|
140 |
+
header("Expires: 0");
|
141 |
+
|
142 |
+
// how to seperate data ##
|
143 |
+
$seperator = "\t"; //tabbed character
|
144 |
+
|
145 |
+
break;
|
146 |
+
|
147 |
+
}
|
148 |
+
|
149 |
+
// line break ##
|
150 |
+
$breaker = "\n";
|
151 |
+
|
152 |
+
// function to exclude data ##
|
153 |
+
$exclude_data = apply_filters( 'q_eud_exclude_data', array() );
|
154 |
+
|
155 |
+
// check for selected usermeta fields ##
|
156 |
+
$usermeta = $_POST['usermeta'];
|
157 |
+
$usermeta_fields = array();
|
158 |
+
foreach( $usermeta as $field ) {
|
159 |
+
$usermeta_fields[] = $field;
|
160 |
+
}
|
161 |
+
|
162 |
+
// array of usermeta fields to include ##
|
163 |
+
/*
|
164 |
+
$usermeta_fields = array(
|
165 |
+
'member_of_club', // program ID ##
|
166 |
+
'last_activity', // last BP activity ##
|
167 |
+
'q_api_u_key', // Adage registration key ##
|
168 |
+
'rewards_milestone', // if reward milestone reached ##
|
169 |
+
'total_friend_count', // BP friend count ##
|
170 |
+
);
|
171 |
+
*/
|
172 |
+
|
173 |
+
// check for selected x profile fields ##
|
174 |
+
$bp_fields = $_POST['bp_fields'];
|
175 |
+
$bp_fields_passed = array();
|
176 |
+
foreach( $bp_fields as $field ) {
|
177 |
+
|
178 |
+
// reverse tidy ##
|
179 |
+
$field = str_replace( '__', ' ', $field );
|
180 |
+
|
181 |
+
// add to array ##
|
182 |
+
$bp_fields_passed[] = $field;
|
183 |
+
|
184 |
+
}
|
185 |
+
|
186 |
+
// global wpdb object ##
|
187 |
+
global $wpdb;
|
188 |
+
|
189 |
+
// requested user data ##
|
190 |
+
$data_keys = array(
|
191 |
+
'ID', 'user_login', 'user_pass',
|
192 |
+
'user_nicename', 'user_email', 'user_url',
|
193 |
+
'user_registered', /*'user_activation_key',*/ /*'user_status',*/
|
194 |
+
'display_name'
|
195 |
+
);
|
196 |
+
|
197 |
+
// compile final fields list ##
|
198 |
+
$fields = array_merge( $data_keys, $usermeta_fields, $bp_fields_passed );
|
199 |
+
|
200 |
+
// build the document headers ##
|
201 |
+
$headers = array();
|
202 |
+
foreach ( $fields as $key => $field ) {
|
203 |
+
|
204 |
+
// rename programs field ##
|
205 |
+
if ( $field == 'member_of_club' ){
|
206 |
+
$field = 'Program';
|
207 |
+
}
|
208 |
+
|
209 |
+
if ( in_array( $field, $exclude_data ) )
|
210 |
+
unset( $fields[$key] );
|
211 |
+
else
|
212 |
+
$headers[] = '"' . $field . '"';
|
213 |
+
|
214 |
+
}
|
215 |
+
|
216 |
+
// echo headers ##
|
217 |
+
echo implode( $seperator, $headers ) . $breaker;
|
218 |
+
|
219 |
+
// build row values for each user ##
|
220 |
+
foreach ( $users as $user ) {
|
221 |
+
|
222 |
+
$data = array();
|
223 |
+
foreach ( $fields as $field ) {
|
224 |
+
|
225 |
+
// BP loaded ? ##
|
226 |
+
if ( function_exists ('bp_is_active') ) {
|
227 |
+
$bp_data = BP_XProfile_ProfileData::get_all_for_user($user->ID);
|
228 |
+
}
|
229 |
+
|
230 |
+
// check if this is a BP field ##
|
231 |
+
if ( in_array( $field, $bp_fields_passed ) ) {
|
232 |
+
|
233 |
+
$value = $bp_data[$field];
|
234 |
+
|
235 |
+
if (is_array($value)) {
|
236 |
+
$value = $value['field_data'];
|
237 |
+
}
|
238 |
+
$value = $this->sanitize($value);
|
239 |
+
|
240 |
+
// user data or usermeta ##
|
241 |
+
} else {
|
242 |
+
|
243 |
+
$value = isset( $user->{$field} ) ? $user->{$field} : '';
|
244 |
+
$value = is_array( $value ) ? serialize( $value ) : $value;
|
245 |
+
|
246 |
+
}
|
247 |
+
|
248 |
+
// correct program value to Program Name ##
|
249 |
+
if ( $field == 'member_of_club' ){
|
250 |
+
$value = get_the_title($value);
|
251 |
+
}
|
252 |
+
|
253 |
+
$data[] = '"' . str_replace( '"', '""', $value ) . '"';
|
254 |
+
|
255 |
+
}
|
256 |
+
|
257 |
+
// echo row data ##
|
258 |
+
echo implode( $seperator, $data ) . $breaker;
|
259 |
+
}
|
260 |
+
|
261 |
+
// stop PHP, so file can export correctly ##
|
262 |
+
exit;
|
263 |
+
}
|
264 |
+
}
|
265 |
+
|
266 |
+
/**
|
267 |
+
* Content of the settings page
|
268 |
+
*
|
269 |
+
* @since 0.1
|
270 |
+
**/
|
271 |
+
public function users_page() {
|
272 |
+
if ( ! current_user_can( 'list_users' ) ) {
|
273 |
+
wp_die( __( 'You do not have sufficient permissions to access this page.', 'export-user-data' ) );
|
274 |
+
}
|
275 |
+
?>
|
276 |
+
|
277 |
+
<div class="wrap">
|
278 |
+
<h2><?php _e( 'Export User Data', 'export-user-data' ); ?></h2>
|
279 |
+
<?php
|
280 |
+
|
281 |
+
// nothing happening? ##
|
282 |
+
if ( isset( $_GET['error'] ) ) {
|
283 |
+
echo '<div class="updated"><p><strong>' . __( 'No users found.', 'export-user-data' ) . '</strong></p></div>';
|
284 |
+
}
|
285 |
+
|
286 |
+
?>
|
287 |
+
<form method="post" action="" enctype="multipart/form-data">
|
288 |
+
<?php wp_nonce_field( 'q-eud-export-user-page_export', '_wpnonce-q-eud-export-user-page_export' ); ?>
|
289 |
+
<table class="form-table">
|
290 |
+
<?php
|
291 |
+
|
292 |
+
// allow admin to select user meta fields to export ##
|
293 |
+
global $wpdb;
|
294 |
+
$meta_keys = $wpdb->get_results( "SELECT distinct(meta_key) FROM $wpdb->usermeta" );
|
295 |
+
|
296 |
+
// get meta_key value from object ##
|
297 |
+
$meta_keys = wp_list_pluck( $meta_keys, 'meta_key' );
|
298 |
+
|
299 |
+
// let's ditch some of them odd keys ##
|
300 |
+
$meta_keys_drop = array(
|
301 |
+
'metaboxhidden',
|
302 |
+
'activation',
|
303 |
+
'bp_',
|
304 |
+
'nav_',
|
305 |
+
'wp_',
|
306 |
+
'admin_color',
|
307 |
+
'wpmudev',
|
308 |
+
'screen_',
|
309 |
+
'show_',
|
310 |
+
'rich_',
|
311 |
+
'reward_',
|
312 |
+
'meta-box',
|
313 |
+
'manageedit',
|
314 |
+
'edit_',
|
315 |
+
'closedpostboxes_',
|
316 |
+
'dismissed_',
|
317 |
+
'manage',
|
318 |
+
'comment',
|
319 |
+
'current',
|
320 |
+
'incentive_',
|
321 |
+
'_wdp',
|
322 |
+
'ssl',
|
323 |
+
'wdfb',
|
324 |
+
'users_per_page',
|
325 |
+
);
|
326 |
+
|
327 |
+
// allow array to be filtered ##
|
328 |
+
$meta_keys_drop = apply_filters( 'export_user_data_meta_keys_drop', $meta_keys_drop );
|
329 |
+
|
330 |
+
foreach ( $meta_keys as $key ) {
|
331 |
+
|
332 |
+
foreach ( $meta_keys_drop as $drop ) {
|
333 |
+
|
334 |
+
if ( strpos( $key, $drop ) !== false ) {
|
335 |
+
|
336 |
+
#echo 'FOUND -- '.$drop.' in '.$key.'<br />';
|
337 |
+
|
338 |
+
if(($key = array_search($key, $meta_keys)) !== false) {
|
339 |
+
unset($meta_keys[$key]);
|
340 |
+
}
|
341 |
+
|
342 |
+
}
|
343 |
+
|
344 |
+
}
|
345 |
+
|
346 |
+
}
|
347 |
+
|
348 |
+
// test array ##
|
349 |
+
#echo '<pre>'; var_dump($meta_keys); echo '</pre>';
|
350 |
+
|
351 |
+
// check if we got anything ? ##
|
352 |
+
if ( $meta_keys ) {
|
353 |
+
|
354 |
+
?>
|
355 |
+
<tr valign="top">
|
356 |
+
<th scope="row"><label for="q_eud_usermeta"><?php _e( 'User Meta Fields', 'export-user-data' ); ?></label></th>
|
357 |
+
<td>
|
358 |
+
<?php
|
359 |
+
|
360 |
+
foreach ( $meta_keys as $key ) {
|
361 |
+
|
362 |
+
#echo "\n\t<option value='" . esc_attr( $role ) . "'>$name</option>";
|
363 |
+
|
364 |
+
// display $key ##
|
365 |
+
$display_key = $key;
|
366 |
+
|
367 |
+
// rename programs field ##
|
368 |
+
if ( $display_key == 'member_of_club' ){
|
369 |
+
$display_key = 'program';
|
370 |
+
}
|
371 |
+
|
372 |
+
// tidy ##
|
373 |
+
$display_key = str_replace( "_", " ", ucwords($display_key) );
|
374 |
+
|
375 |
+
echo "<label for='".esc_attr( $key )."' title='".esc_attr( $key )."'><input id='".esc_attr( $key )."' type='checkbox' name='usermeta[]' value='".esc_attr( $key )."'/> $display_key</label><br />";
|
376 |
+
}
|
377 |
+
?>
|
378 |
+
</td>
|
379 |
+
</tr>
|
380 |
+
<?php
|
381 |
+
|
382 |
+
} // meta_keys found ##
|
383 |
+
|
384 |
+
?>
|
385 |
+
<?php
|
386 |
+
|
387 |
+
// buddypress x profile data ##
|
388 |
+
if ( function_exists ('bp_is_active') ) {
|
389 |
+
|
390 |
+
// grab all buddypress x profile fields ##
|
391 |
+
$bp_fields = $wpdb->get_results( "SELECT distinct(name) FROM ".$wpdb->base_prefix."bp_xprofile_fields WHERE parent_id = 0" );
|
392 |
+
|
393 |
+
// get name value from object ##
|
394 |
+
$bp_fields = wp_list_pluck( $bp_fields, 'name' );
|
395 |
+
|
396 |
+
// test array ##
|
397 |
+
#echo '<pre>'; var_dump($bp_fields); echo '</pre>';
|
398 |
+
|
399 |
+
// allow array to be filtered ##
|
400 |
+
$bp_fields = apply_filters( 'export_user_data_bp_fields', $bp_fields );
|
401 |
+
|
402 |
+
?>
|
403 |
+
<tr valign="top">
|
404 |
+
<th scope="row"><label for="q_eud_xprofile"><?php _e( 'BP xProfile Fields', 'export-user-data' ); ?></label></th>
|
405 |
+
<td>
|
406 |
+
<?php
|
407 |
+
|
408 |
+
foreach ( $bp_fields as $key ) {
|
409 |
+
|
410 |
+
// tidy up key ##
|
411 |
+
$key_tidy = str_replace( ' ', '__', ($key));
|
412 |
+
|
413 |
+
echo "<label for='".esc_attr( $key_tidy )."'><input id='".esc_attr( $key_tidy )."' type='checkbox' name='bp_fields[]' value='".esc_attr( $key_tidy )."'/> $key</label><br />";
|
414 |
+
}
|
415 |
+
?>
|
416 |
+
</td>
|
417 |
+
</tr>
|
418 |
+
<?php
|
419 |
+
|
420 |
+
} // BP installed and active ##
|
421 |
+
|
422 |
+
?>
|
423 |
+
<tr valign="top">
|
424 |
+
<th scope="row"><label for="q_eud_users_role"><?php _e( 'Role', 'export-user-data' ); ?></label></th>
|
425 |
+
<td>
|
426 |
+
<select name="role" id="q_eud_users_role">
|
427 |
+
<?php
|
428 |
+
|
429 |
+
echo '<option value="">' . __( 'All Roles', 'export-user-data' ) . '</option>';
|
430 |
+
global $wp_roles;
|
431 |
+
foreach ( $wp_roles->role_names as $role => $name ) {
|
432 |
+
echo "\n\t<option value='" . esc_attr( $role ) . "'>$name</option>";
|
433 |
+
}
|
434 |
+
|
435 |
+
?>
|
436 |
+
</select>
|
437 |
+
</td>
|
438 |
+
</tr>
|
439 |
+
<?php
|
440 |
+
|
441 |
+
// clubs ? ##
|
442 |
+
if ( post_type_exists( 'club' ) ) {
|
443 |
+
|
444 |
+
?>
|
445 |
+
<tr valign="top">
|
446 |
+
<th scope="row"><label for="q_eud_users_program"><?php _e( 'Programs', 'export-user-data' ); ?></label></th>
|
447 |
+
<td>
|
448 |
+
<select name="program" id="q_eud_users_program">
|
449 |
+
<?php
|
450 |
+
|
451 |
+
echo '<option value="">' . __( 'All Programs', 'export-user-data' ) . '</option>';
|
452 |
+
|
453 |
+
$clubs_array = get_posts(array( 'post_type'=> 'club', 'posts_per_page' => -1 )); // grab all posts of type "club" ##
|
454 |
+
|
455 |
+
foreach ( $clubs_array as $c ) { // loop over all clubs ##
|
456 |
+
|
457 |
+
#$clubs[$c->ID] = $c; // grab club ID ##
|
458 |
+
echo "\n\t<option value='" . esc_attr( $c->ID ) . "'>$c->post_title</option>";
|
459 |
+
|
460 |
+
}
|
461 |
+
|
462 |
+
?>
|
463 |
+
</select>
|
464 |
+
</td>
|
465 |
+
</tr>
|
466 |
+
<?php
|
467 |
+
|
468 |
+
} // clubs ##
|
469 |
+
|
470 |
+
?>
|
471 |
+
<tr valign="top">
|
472 |
+
<th scope="row"><label><?php _e( 'Registred', 'export-user-data' ); ?></label></th>
|
473 |
+
<td>
|
474 |
+
<select name="start_date" id="q_eud_users_start_date">
|
475 |
+
<option value="0"><?php _e( 'Start Date', 'export-user-data' ); ?></option>
|
476 |
+
<?php $this->export_date_options(); ?>
|
477 |
+
</select>
|
478 |
+
<select name="end_date" id="q_eud_users_end_date">
|
479 |
+
<option value="0"><?php _e( 'End Date', 'export-user-data' ); ?></option>
|
480 |
+
<?php $this->export_date_options(); ?>
|
481 |
+
</select>
|
482 |
+
</td>
|
483 |
+
</tr>
|
484 |
+
|
485 |
+
<tr valign="top">
|
486 |
+
<th scope="row"><label for="q_eud_users_format"><?php _e( 'Format', 'export-user-data' ); ?></label></th>
|
487 |
+
<td>
|
488 |
+
<select name="format" id="q_eud_users_format">
|
489 |
+
<?php
|
490 |
+
|
491 |
+
echo '<option value="excel">' . __( 'Excel', 'export-user-data' ) . '</option>';
|
492 |
+
echo '<option value="csv">' . __( 'CSV', 'export-user-data' ) . '</option>';
|
493 |
+
|
494 |
+
?>
|
495 |
+
</select>
|
496 |
+
</td>
|
497 |
+
</tr>
|
498 |
+
</table>
|
499 |
+
<p class="submit">
|
500 |
+
<input type="hidden" name="_wp_http_referer" value="<?php echo $_SERVER['REQUEST_URI'] ?>" />
|
501 |
+
<input type="submit" class="button-primary" value="<?php _e( 'Export', 'export-user-data' ); ?>" />
|
502 |
+
</p>
|
503 |
+
</form>
|
504 |
+
<?php
|
505 |
+
}
|
506 |
+
|
507 |
+
// data to exclude from export ##
|
508 |
+
public function exclude_data() {
|
509 |
+
$exclude = array( 'user_pass', 'user_activation_key' );
|
510 |
+
return $exclude;
|
511 |
+
}
|
512 |
+
|
513 |
+
public function pre_user_query( $user_search ) {
|
514 |
+
global $wpdb;
|
515 |
+
|
516 |
+
$where = '';
|
517 |
+
|
518 |
+
if ( ! empty( $_POST['start_date'] ) )
|
519 |
+
$where .= $wpdb->prepare( " AND $wpdb->users.user_registered >= %s", date( 'Y-m-d', strtotime( $_POST['start_date'] ) ) );
|
520 |
+
|
521 |
+
if ( ! empty( $_POST['end_date'] ) )
|
522 |
+
$where .= $wpdb->prepare( " AND $wpdb->users.user_registered < %s", date( 'Y-m-d', strtotime( '+1 month', strtotime( $_POST['end_date'] ) ) ) );
|
523 |
+
|
524 |
+
if ( ! empty( $where ) )
|
525 |
+
$user_search->query_where = str_replace( 'WHERE 1=1', "WHERE 1=1 $where", $user_search->query_where );
|
526 |
+
|
527 |
+
return $user_search;
|
528 |
+
}
|
529 |
+
|
530 |
+
private function export_date_options() {
|
531 |
+
global $wpdb, $wp_locale;
|
532 |
+
|
533 |
+
$months = $wpdb->get_results( "
|
534 |
+
SELECT DISTINCT YEAR( user_registered ) AS year, MONTH( user_registered ) AS month
|
535 |
+
FROM $wpdb->users
|
536 |
+
ORDER BY user_registered DESC
|
537 |
+
" );
|
538 |
+
|
539 |
+
$month_count = count( $months );
|
540 |
+
if ( !$month_count || ( 1 == $month_count && 0 == $months[0]->month ) )
|
541 |
+
return;
|
542 |
+
|
543 |
+
foreach ( $months as $date ) {
|
544 |
+
if ( 0 == $date->year )
|
545 |
+
continue;
|
546 |
+
|
547 |
+
$month = zeroise( $date->month, 2 );
|
548 |
+
echo '<option value="' . $date->year . '-' . $month . '">' . $wp_locale->get_month( $month ) . ' ' . $date->year . '</option>';
|
549 |
+
}
|
550 |
+
}
|
551 |
+
}
|
552 |
+
|
553 |
+
new Q_EUD_Export_Users;
|
languages/default.mo
ADDED
Binary file
|
languages/default.po
ADDED
@@ -0,0 +1,82 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
msgid ""
|
2 |
+
msgstr ""
|
3 |
+
"Project-Id-Version: Export User Data 0.5\n"
|
4 |
+
"Report-Msgid-Bugs-To: http://wordpress.org/tag/export-users-to-csv\n"
|
5 |
+
"POT-Creation-Date: 2013-08-12 16:30-0000\n"
|
6 |
+
"PO-Revision-Date: 2013-08-12 16:30-0000\n"
|
7 |
+
"Last-Translator: Ray <studio@quintalinda.com>\n"
|
8 |
+
"Language-Team: Q Studio <team@qstudio.us>\n"
|
9 |
+
"Language: en\n"
|
10 |
+
"MIME-Version: 1.0\n"
|
11 |
+
"Content-Type: text/plain; charset=UTF-8\n"
|
12 |
+
"Content-Transfer-Encoding: 8bit\n"
|
13 |
+
"X-Generator: Poedit 1.5.4\n"
|
14 |
+
"X-Poedit-KeywordsList: _;_e;_n;__\n"
|
15 |
+
"X-Poedit-Basepath: .\n"
|
16 |
+
"Plural-Forms: s;\n"
|
17 |
+
"X-Poedit-SourceCharset: UTF-8\n"
|
18 |
+
"X-Poedit-SearchPath-0: .\n"
|
19 |
+
|
20 |
+
#: export-user-data.php:59 export-user-data.php:278
|
21 |
+
msgid "Export User Data"
|
22 |
+
msgstr ""
|
23 |
+
|
24 |
+
#: export-user-data.php:273
|
25 |
+
msgid "You do not have sufficient permissions to access this page."
|
26 |
+
msgstr ""
|
27 |
+
|
28 |
+
#: export-user-data.php:283
|
29 |
+
msgid "No users found."
|
30 |
+
msgstr ""
|
31 |
+
|
32 |
+
#: export-user-data.php:356
|
33 |
+
msgid "User Meta Fields"
|
34 |
+
msgstr ""
|
35 |
+
|
36 |
+
#: export-user-data.php:404
|
37 |
+
msgid "BP xProfile Fields"
|
38 |
+
msgstr ""
|
39 |
+
|
40 |
+
#: export-user-data.php:424
|
41 |
+
msgid "Role"
|
42 |
+
msgstr ""
|
43 |
+
|
44 |
+
#: export-user-data.php:429
|
45 |
+
msgid "All Roles"
|
46 |
+
msgstr ""
|
47 |
+
|
48 |
+
#: export-user-data.php:446
|
49 |
+
msgid "Programs"
|
50 |
+
msgstr ""
|
51 |
+
|
52 |
+
#: export-user-data.php:451
|
53 |
+
msgid "All Programs"
|
54 |
+
msgstr ""
|
55 |
+
|
56 |
+
#: export-user-data.php:472
|
57 |
+
msgid "Registred"
|
58 |
+
msgstr ""
|
59 |
+
|
60 |
+
#: export-user-data.php:475
|
61 |
+
msgid "Start Date"
|
62 |
+
msgstr ""
|
63 |
+
|
64 |
+
#: export-user-data.php:479
|
65 |
+
msgid "End Date"
|
66 |
+
msgstr ""
|
67 |
+
|
68 |
+
#: export-user-data.php:486
|
69 |
+
msgid "Format"
|
70 |
+
msgstr ""
|
71 |
+
|
72 |
+
#: export-user-data.php:491
|
73 |
+
msgid "Excel"
|
74 |
+
msgstr ""
|
75 |
+
|
76 |
+
#: export-user-data.php:492
|
77 |
+
msgid "CSV"
|
78 |
+
msgstr ""
|
79 |
+
|
80 |
+
#: export-user-data.php:501
|
81 |
+
msgid "Export"
|
82 |
+
msgstr ""
|
readme.txt
ADDED
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
=== Plugin Name ===
|
2 |
+
Contributors: Q Studio sorich87
|
3 |
+
Tags: user, users, xprofile, usermeta csv, excel, batch, export, exporter, admin
|
4 |
+
Requires at least: 3.2
|
5 |
+
Tested up to: 3.6
|
6 |
+
Stable tag: 0.5.1
|
7 |
+
Original: http://wordpress.org/plugins/export-users-to-csv/
|
8 |
+
License: GPLv2
|
9 |
+
|
10 |
+
Export users data, metadata and buddypress xprofile data to a csv or Excel file
|
11 |
+
|
12 |
+
== Description ==
|
13 |
+
|
14 |
+
A plugin that export ALL user data, meta data and BuddyPress xProfile data.
|
15 |
+
|
16 |
+
Includes an option to export the users by role, registration date range, usermeta option and two export formats.
|
17 |
+
|
18 |
+
= Features =
|
19 |
+
|
20 |
+
* Exports all users fields
|
21 |
+
* Exports users meta
|
22 |
+
* Exports users by role
|
23 |
+
* Exports users by date range
|
24 |
+
* Export user BuddyPress xProfile data
|
25 |
+
|
26 |
+
For feature request and bug reports, [please use the forums](http://wordpress.org/tags/export-users-data).
|
27 |
+
|
28 |
+
== Installation ==
|
29 |
+
|
30 |
+
For an automatic installation through WordPress:
|
31 |
+
|
32 |
+
1. Go to the 'Add New' plugins screen in your WordPress admin area
|
33 |
+
1. Search for 'Export User Data'
|
34 |
+
1. Click 'Install Now' and activate the plugin
|
35 |
+
1. Go the 'Users' menu, under 'Export User Data'
|
36 |
+
|
37 |
+
|
38 |
+
For a manual installation via FTP:
|
39 |
+
|
40 |
+
1. Upload the `export-user-data` directory to the `/wp-content/plugins/` directory
|
41 |
+
1. Activate the plugin through the 'Plugins' screen in your WordPress admin area
|
42 |
+
1. Go the 'Users' menu, under 'Export User Data'
|
43 |
+
|
44 |
+
|
45 |
+
To upload the plugin through WordPress, instead of FTP:
|
46 |
+
|
47 |
+
1. Upload the downloaded zip file on the 'Add New' plugins screen (see the 'Upload' tab) in your WordPress admin area and activate.
|
48 |
+
1. Go the 'Users' menu, under 'Export User Data'
|
49 |
+
|
50 |
+
== Frequently Asked Questions ==
|
51 |
+
|
52 |
+
= How to use? =
|
53 |
+
|
54 |
+
Click on the 'Export User Data' link in the 'Users' menu, choose the role and the date range or don't select anything if you want to export all users, then click 'Export'. That's all!
|
55 |
+
|
56 |
+
== Screenshots ==
|
57 |
+
|
58 |
+
1. User export screen
|
59 |
+
|
60 |
+
== Changelog ==
|
61 |
+
|
62 |
+
= 0.5 =
|
63 |
+
* First public release.
|
64 |
+
|
65 |
+
== Upgrade Notice ==
|
66 |
+
|
67 |
+
= 0.5 =
|
68 |
+
First release.
|
screenshot-1.png
ADDED
Binary file
|