Version Description
- BP X Profile Export Fix ( > version 2.0 )
Download this release
Release Info
Developer | qlstudio |
Plugin | Export User Data |
Version | 0.9.4 |
Comparing to | |
See all releases |
Code changes from version 0.9.3 to 0.9.4
- export-user-data.php +158 -12
- readme.txt +4 -1
export-user-data.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
Plugin Name: Export User Data
|
5 |
Plugin URI: http://qstudio.us/plugins/
|
6 |
Description: Export User data, metadata and BuddyPressX Profile data.
|
7 |
-
Version: 0.9.
|
8 |
Author: Q Studio
|
9 |
Author URI: http://qstudio.us
|
10 |
License: GPL2
|
@@ -19,7 +19,7 @@ if ( ! class_exists( 'Q_Export_User_Data' ) )
|
|
19 |
{
|
20 |
|
21 |
// plugin version
|
22 |
-
define( 'Q_EXPORT_USER_DATA_VERSION', '0.9.
|
23 |
|
24 |
// instatiate class via hook, only if inside admin
|
25 |
if ( is_admin() ) {
|
@@ -40,10 +40,10 @@ if ( ! class_exists( 'Q_Export_User_Data' ) )
|
|
40 |
|
41 |
// Refers to a single instance of this class. ##
|
42 |
private static $instance = null;
|
43 |
-
|
44 |
-
|
45 |
/* properties */
|
46 |
public $text_domain = 'export-user-data'; // for translation ##
|
|
|
47 |
|
48 |
|
49 |
/**
|
@@ -74,7 +74,7 @@ if ( ! class_exists( 'Q_Export_User_Data' ) )
|
|
74 |
|
75 |
add_action( 'init', array( $this, 'load_plugin_textdomain' ) );
|
76 |
add_action( 'admin_menu', array( $this, 'add_admin_pages' ) );
|
77 |
-
add_action( 'init', array( $this, 'generate_data' )
|
78 |
add_filter( 'q_eud_exclude_data', array( $this, 'exclude_data' ) );
|
79 |
add_action( 'admin_enqueue_scripts', array( $this, 'add_css_and_js' ), 1 );
|
80 |
add_action( 'admin_footer', array( $this, 'jquery' ), 100000 );
|
@@ -111,7 +111,9 @@ if ( ! class_exists( 'Q_Export_User_Data' ) )
|
|
111 |
}
|
112 |
|
113 |
|
114 |
-
|
|
|
|
|
115 |
public function add_css_and_js( $hook )
|
116 |
{
|
117 |
|
@@ -127,7 +129,9 @@ if ( ! class_exists( 'Q_Export_User_Data' ) )
|
|
127 |
}
|
128 |
|
129 |
|
130 |
-
|
|
|
|
|
131 |
public function sanitize( $value )
|
132 |
{
|
133 |
|
@@ -138,7 +142,87 @@ if ( ! class_exists( 'Q_Export_User_Data' ) )
|
|
138 |
|
139 |
}
|
140 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
141 |
|
|
|
|
|
142 |
/**
|
143 |
* Process content of CSV file
|
144 |
*
|
@@ -147,6 +231,12 @@ if ( ! class_exists( 'Q_Export_User_Data' ) )
|
|
147 |
public function generate_data()
|
148 |
{
|
149 |
|
|
|
|
|
|
|
|
|
|
|
|
|
150 |
if ( ! isset( $_POST['_wpnonce-q-eud-export-user-page_export'] ) ) {
|
151 |
|
152 |
return false;
|
@@ -155,7 +245,10 @@ if ( ! class_exists( 'Q_Export_User_Data' ) )
|
|
155 |
|
156 |
// check admin referer ##
|
157 |
check_admin_referer( 'q-eud-export-user-page_export', '_wpnonce-q-eud-export-user-page_export' );
|
158 |
-
|
|
|
|
|
|
|
159 |
// build argument array ##
|
160 |
$args = array(
|
161 |
#'fields' => 'all_with_meta',
|
@@ -172,7 +265,7 @@ if ( ! class_exists( 'Q_Export_User_Data' ) )
|
|
172 |
|
173 |
}
|
174 |
|
175 |
-
// is
|
176 |
if ( isset( $_POST['limit_offset'] ) && $_POST['limit_offset'] != '' && isset( $_POST['limit_total'] ) && $_POST['limit_total'] != '' ) {
|
177 |
|
178 |
// let's just make sure they are integer values ##
|
@@ -355,6 +448,22 @@ if ( ! class_exists( 'Q_Export_User_Data' ) )
|
|
355 |
// compile final fields list ##
|
356 |
$fields = array_merge( $data_keys, $usermeta_fields, $bp_fields_passed, $bp_fields_update_passed );
|
357 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
358 |
// build the document headers ##
|
359 |
$headers = array();
|
360 |
|
@@ -423,6 +532,12 @@ if ( ! class_exists( 'Q_Export_User_Data' ) )
|
|
423 |
$field_id = xprofile_get_field_id_from_name( $real_field );
|
424 |
$value = $wpdb->get_var ($wpdb->prepare( "SELECT last_updated FROM {$bp->profile->table_name_data} WHERE user_id = %d AND field_id = %d", $user->ID, $field_id ) );
|
425 |
|
|
|
|
|
|
|
|
|
|
|
|
|
426 |
// user data or usermeta ##
|
427 |
} else {
|
428 |
|
@@ -470,8 +585,11 @@ if ( ! class_exists( 'Q_Export_User_Data' ) )
|
|
470 |
if ( ! current_user_can( 'list_users' ) ) {
|
471 |
wp_die( __( 'You do not have sufficient permissions to access this page.', $this->text_domain ) );
|
472 |
}
|
|
|
|
|
|
|
|
|
473 |
?>
|
474 |
-
|
475 |
<div class="wrap">
|
476 |
<h2><?php _e( 'Export User Data', $this->text_domain ); ?></h2>
|
477 |
<?php
|
@@ -556,7 +674,7 @@ if ( ! class_exists( 'Q_Export_User_Data' ) )
|
|
556 |
}
|
557 |
|
558 |
// tidy ##
|
559 |
-
$display_key = str_replace( "_", " ", ucwords($display_key) );
|
560 |
|
561 |
#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 />";
|
562 |
|
@@ -570,7 +688,7 @@ if ( ! class_exists( 'Q_Export_User_Data' ) )
|
|
570 |
#echo 'FOUND -- '.$drop.' in '.$key.'<br />';
|
571 |
// https://wordpress.org/support/topic/bugfix-numbers-in-export-headers?replies=1
|
572 |
// removed $key = assignment, as not required ##
|
573 |
-
if(( array_search($key, $meta_keys)) !== false ) {
|
574 |
|
575 |
$usermeta_class = 'system';
|
576 |
|
@@ -765,6 +883,33 @@ if ( ! class_exists( 'Q_Export_User_Data' ) )
|
|
765 |
</td>
|
766 |
</tr>
|
767 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
768 |
<tr valign="top">
|
769 |
<th scope="row"><label for="q_eud_users_format"><?php _e( 'Format', $this->text_domain ); ?></label></th>
|
770 |
<td>
|
@@ -889,6 +1034,7 @@ if ( ! class_exists( 'Q_Export_User_Data' ) )
|
|
889 |
?>
|
890 |
<style>
|
891 |
.toggleable { display: none; }
|
|
|
892 |
</style>
|
893 |
<?php
|
894 |
}
|
4 |
Plugin Name: Export User Data
|
5 |
Plugin URI: http://qstudio.us/plugins/
|
6 |
Description: Export User data, metadata and BuddyPressX Profile data.
|
7 |
+
Version: 0.9.4
|
8 |
Author: Q Studio
|
9 |
Author URI: http://qstudio.us
|
10 |
License: GPL2
|
19 |
{
|
20 |
|
21 |
// plugin version
|
22 |
+
define( 'Q_EXPORT_USER_DATA_VERSION', '0.9.4' ); // version ##
|
23 |
|
24 |
// instatiate class via hook, only if inside admin
|
25 |
if ( is_admin() ) {
|
40 |
|
41 |
// Refers to a single instance of this class. ##
|
42 |
private static $instance = null;
|
43 |
+
|
|
|
44 |
/* properties */
|
45 |
public $text_domain = 'export-user-data'; // for translation ##
|
46 |
+
#public $q_eud_options = array(); // export settings ##
|
47 |
|
48 |
|
49 |
/**
|
74 |
|
75 |
add_action( 'init', array( $this, 'load_plugin_textdomain' ) );
|
76 |
add_action( 'admin_menu', array( $this, 'add_admin_pages' ) );
|
77 |
+
add_action( 'init', array( $this, 'generate_data' ) );
|
78 |
add_filter( 'q_eud_exclude_data', array( $this, 'exclude_data' ) );
|
79 |
add_action( 'admin_enqueue_scripts', array( $this, 'add_css_and_js' ), 1 );
|
80 |
add_action( 'admin_footer', array( $this, 'jquery' ), 100000 );
|
111 |
}
|
112 |
|
113 |
|
114 |
+
/**
|
115 |
+
* style and interaction
|
116 |
+
*/
|
117 |
public function add_css_and_js( $hook )
|
118 |
{
|
119 |
|
129 |
}
|
130 |
|
131 |
|
132 |
+
/**
|
133 |
+
* clean that stuff up
|
134 |
+
*/
|
135 |
public function sanitize( $value )
|
136 |
{
|
137 |
|
142 |
|
143 |
}
|
144 |
|
145 |
+
|
146 |
+
/**
|
147 |
+
* Check for a retrieve stored user options
|
148 |
+
*
|
149 |
+
* @since 0.9.3
|
150 |
+
* @return Mixed false on error OR array of saved options
|
151 |
+
*/
|
152 |
+
public function get_user_options()
|
153 |
+
{
|
154 |
+
|
155 |
+
// check if the user wants to, or has previously saved the export field list ##
|
156 |
+
$user_ID = get_current_user_id();
|
157 |
+
|
158 |
+
// no user - go return false ##
|
159 |
+
if ( ! $user_ID ) { return false; }
|
160 |
+
|
161 |
+
// return an empty array, if nothing found ##
|
162 |
+
return get_option( 'q_eud_options_'.$user_ID, array() );
|
163 |
+
|
164 |
+
}
|
165 |
+
|
166 |
+
|
167 |
+
/**
|
168 |
+
* method to store user options
|
169 |
+
*
|
170 |
+
* @since 0.9.3
|
171 |
+
* @return Boolean
|
172 |
+
*/
|
173 |
+
public function set_user_options( $value = null )
|
174 |
+
{
|
175 |
+
|
176 |
+
// nothing cooking ##
|
177 |
+
if ( is_null( $value ) ) {
|
178 |
+
|
179 |
+
return false;
|
180 |
+
|
181 |
+
}
|
182 |
+
|
183 |
+
// add value to property ##
|
184 |
+
$this->q_eud_options[] = $value;
|
185 |
+
|
186 |
+
}
|
187 |
+
|
188 |
+
|
189 |
+
/**
|
190 |
+
* method to save / update / delete user options
|
191 |
+
*
|
192 |
+
* @since 0.9.3
|
193 |
+
* @return Boolean
|
194 |
+
*/
|
195 |
+
public function manage_user_options( $action = null )
|
196 |
+
{
|
197 |
+
|
198 |
+
// nothing cooking ##
|
199 |
+
if ( is_null( $action ) ) {
|
200 |
+
|
201 |
+
return false;
|
202 |
+
|
203 |
+
}
|
204 |
+
|
205 |
+
// check if the user wants to, or has previously saved the export field list ##
|
206 |
+
$user_ID = get_current_user_id();
|
207 |
+
|
208 |
+
// no user - go return false ##
|
209 |
+
if ( ! $user_ID ) { return false; }
|
210 |
+
|
211 |
+
// what action to take ##
|
212 |
+
switch ( $action ) {
|
213 |
+
|
214 |
+
case ( 'save' ):
|
215 |
+
|
216 |
+
update_option( 'q_eud_options_'.$user_ID, $this->q_eud_options );
|
217 |
+
|
218 |
+
break;
|
219 |
+
|
220 |
+
}
|
221 |
+
|
222 |
+
}
|
223 |
|
224 |
+
|
225 |
+
|
226 |
/**
|
227 |
* Process content of CSV file
|
228 |
*
|
231 |
public function generate_data()
|
232 |
{
|
233 |
|
234 |
+
#if ( ! current_user_can( 'list_users' ) ) {
|
235 |
+
|
236 |
+
#wp_die( __( 'You do not have sufficient permissions to access this page.', $this->text_domain ) );
|
237 |
+
|
238 |
+
#}
|
239 |
+
|
240 |
if ( ! isset( $_POST['_wpnonce-q-eud-export-user-page_export'] ) ) {
|
241 |
|
242 |
return false;
|
245 |
|
246 |
// check admin referer ##
|
247 |
check_admin_referer( 'q-eud-export-user-page_export', '_wpnonce-q-eud-export-user-page_export' );
|
248 |
+
|
249 |
+
// check for a retrieve user's stored options ##
|
250 |
+
#$q_eud_options = $this->get_user_options();
|
251 |
+
|
252 |
// build argument array ##
|
253 |
$args = array(
|
254 |
#'fields' => 'all_with_meta',
|
265 |
|
266 |
}
|
267 |
|
268 |
+
// is there a range limit in place for the export ? ##
|
269 |
if ( isset( $_POST['limit_offset'] ) && $_POST['limit_offset'] != '' && isset( $_POST['limit_total'] ) && $_POST['limit_total'] != '' ) {
|
270 |
|
271 |
// let's just make sure they are integer values ##
|
448 |
// compile final fields list ##
|
449 |
$fields = array_merge( $data_keys, $usermeta_fields, $bp_fields_passed, $bp_fields_update_passed );
|
450 |
|
451 |
+
// should we include the user's role in the export ##
|
452 |
+
/*
|
453 |
+
if ( isset( $_POST['q_eud_role'] ) && $_POST['q_eud_role'] != '' ) {
|
454 |
+
|
455 |
+
// save this to stored options ( 'group', 'field', 'value' )##
|
456 |
+
$this->set_user_options( array( 'role' => array ( 'q_eud_role' => array ( 'yes' ) ) ) );
|
457 |
+
|
458 |
+
// save options ##
|
459 |
+
$this->manage_user_options( 'save' );
|
460 |
+
|
461 |
+
// add "Role" to the fields array ##
|
462 |
+
$fields[]["role"] = _e( 'Role', $this->text_domain );
|
463 |
+
|
464 |
+
}
|
465 |
+
*/
|
466 |
+
|
467 |
// build the document headers ##
|
468 |
$headers = array();
|
469 |
|
532 |
$field_id = xprofile_get_field_id_from_name( $real_field );
|
533 |
$value = $wpdb->get_var ($wpdb->prepare( "SELECT last_updated FROM {$bp->profile->table_name_data} WHERE user_id = %d AND field_id = %d", $user->ID, $field_id ) );
|
534 |
|
535 |
+
// include the user's role in the export ##
|
536 |
+
} elseif ( isset( $_POST['q_eud_role'] ) && $_POST['q_eud_role'] != '' && $field == 'role' ){
|
537 |
+
|
538 |
+
// add "Role" as $value ##
|
539 |
+
$value = $user->roles[0] ? $user->roles[0] : '' ; // empty value if no role found ##
|
540 |
+
|
541 |
// user data or usermeta ##
|
542 |
} else {
|
543 |
|
585 |
if ( ! current_user_can( 'list_users' ) ) {
|
586 |
wp_die( __( 'You do not have sufficient permissions to access this page.', $this->text_domain ) );
|
587 |
}
|
588 |
+
|
589 |
+
// check for a retrieve user's stroed options ##
|
590 |
+
#$q_eud_options = $this->get_user_options();
|
591 |
+
|
592 |
?>
|
|
|
593 |
<div class="wrap">
|
594 |
<h2><?php _e( 'Export User Data', $this->text_domain ); ?></h2>
|
595 |
<?php
|
674 |
}
|
675 |
|
676 |
// tidy ##
|
677 |
+
$display_key = str_replace( "_", " ", ucwords( $display_key ) );
|
678 |
|
679 |
#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 />";
|
680 |
|
688 |
#echo 'FOUND -- '.$drop.' in '.$key.'<br />';
|
689 |
// https://wordpress.org/support/topic/bugfix-numbers-in-export-headers?replies=1
|
690 |
// removed $key = assignment, as not required ##
|
691 |
+
if ( ( array_search( $key, $meta_keys ) ) !== false ) {
|
692 |
|
693 |
$usermeta_class = 'system';
|
694 |
|
883 |
</td>
|
884 |
</tr>
|
885 |
|
886 |
+
<tr valign="top" class="hidden">
|
887 |
+
<th scope="row"><label for="q_eud_role"><?php _e( 'Include Role', $this->text_domain ); ?></label></th>
|
888 |
+
<td>
|
889 |
+
<input id='q_eud_role' type='checkbox' name='q_eud_role' value=''/></label>
|
890 |
+
<p class="description"><?php
|
891 |
+
printf(
|
892 |
+
__( 'Checking this option will add a column that includes the user\'s role.', $this->text_domain )
|
893 |
+
);
|
894 |
+
?></p>
|
895 |
+
</td>
|
896 |
+
</tr>
|
897 |
+
</tr>
|
898 |
+
|
899 |
+
<tr valign="top" class="hidden">
|
900 |
+
<th scope="row">
|
901 |
+
<label for="q_eud_options"><?php _e( 'Remember Options', $this->text_domain ); ?>
|
902 |
+
</th>
|
903 |
+
<td>
|
904 |
+
<input id='q_eud_options' type='checkbox' name='q_eud_options' value=''/></label>
|
905 |
+
<p class="description"><?php
|
906 |
+
printf(
|
907 |
+
__( 'Checking this option will save and reload your selected options for future exports.', $this->text_domain )
|
908 |
+
);
|
909 |
+
?></p>
|
910 |
+
</td>
|
911 |
+
</tr>
|
912 |
+
|
913 |
<tr valign="top">
|
914 |
<th scope="row"><label for="q_eud_users_format"><?php _e( 'Format', $this->text_domain ); ?></label></th>
|
915 |
<td>
|
1034 |
?>
|
1035 |
<style>
|
1036 |
.toggleable { display: none; }
|
1037 |
+
.hidden { display: none; }
|
1038 |
</style>
|
1039 |
<?php
|
1040 |
}
|
readme.txt
CHANGED
@@ -3,7 +3,7 @@ Contributors: qlstudio
|
|
3 |
Tags: user, users, xprofile, usermeta csv, excel, batch, export, save, download
|
4 |
Requires at least: 3.2
|
5 |
Tested up to: 3.9.0
|
6 |
-
Stable tag: 0.9.
|
7 |
License: GPLv2
|
8 |
|
9 |
Export users data, metadata and buddypress xprofile data to a csv or Excel file
|
@@ -58,6 +58,9 @@ Click on the 'Export User Data' link in the 'Users' menu, choose the role and th
|
|
58 |
|
59 |
== Changelog ==
|
60 |
|
|
|
|
|
|
|
61 |
= 0.9.3 =
|
62 |
* fix for hidden admin bar
|
63 |
|
3 |
Tags: user, users, xprofile, usermeta csv, excel, batch, export, save, download
|
4 |
Requires at least: 3.2
|
5 |
Tested up to: 3.9.0
|
6 |
+
Stable tag: 0.9.4
|
7 |
License: GPLv2
|
8 |
|
9 |
Export users data, metadata and buddypress xprofile data to a csv or Excel file
|
58 |
|
59 |
== Changelog ==
|
60 |
|
61 |
+
= 0.9.4 =
|
62 |
+
* BP X Profile Export Fix ( > version 2.0 )
|
63 |
+
|
64 |
= 0.9.3 =
|
65 |
* fix for hidden admin bar
|
66 |
|