Version Description
- Export now can be ordered using an attribute in the shortcode, attributes are orderby and order, how to use them it is explained there
Download this release
Release Info
Developer | carazo |
Plugin | Import users from CSV with meta |
Version | 1.17.9 |
Comparing to | |
See all releases |
Code changes from version 1.17.8.4 to 1.17.9
- classes/export.php +21 -3
- classes/frontend.php +26 -1
- import-users-from-csv-with-meta.php +1 -1
- readme.txt +3 -0
classes/export.php
CHANGED
@@ -4,12 +4,16 @@ if ( ! defined( 'ABSPATH' ) ) exit;
|
|
4 |
class ACUI_Exporter{
|
5 |
private $path_csv;
|
6 |
private $user_data;
|
|
|
|
|
|
|
7 |
|
8 |
function __construct(){
|
9 |
$upload_dir = wp_upload_dir();
|
10 |
|
11 |
$this->path_csv = $upload_dir['basedir'] . "/export-users.csv";
|
12 |
$this->user_data = array( "user_login", "user_email", "source_user_id", "user_pass", "user_nicename", "user_url", "user_registered", "display_name" );
|
|
|
13 |
$this->woocommerce_default_user_meta_keys = array( 'billing_first_name', 'billing_last_name', 'billing_email', 'billing_phone', 'billing_country', 'billing_address_1', 'billing_city', 'billing_state', 'billing_postcode', 'shipping_first_name', 'shipping_last_name', 'shipping_country', 'shipping_address_1', 'shipping_address_2', 'shipping_city', 'shipping_state', 'shipping_postcode' );
|
14 |
$this->other_non_date_keys = array( 'shipping_phone' );
|
15 |
|
@@ -241,6 +245,8 @@ class ACUI_Exporter{
|
|
241 |
$double_encapsulate_serialized_values = isset( $_POST['double_encapsulate_serialized_values'] ) && !empty( $_POST['double_encapsulate_serialized_values'] );
|
242 |
$filtered_columns = ( isset( $_POST['columns'] ) && !empty( $_POST['columns'] ) ) ? $_POST['columns'] : array();
|
243 |
$filtered_columns = $this->manage_filtered_columns( $filtered_columns );
|
|
|
|
|
244 |
|
245 |
switch ( $delimiter ) {
|
246 |
case 'COMMA':
|
@@ -288,7 +294,7 @@ class ACUI_Exporter{
|
|
288 |
$row = array();
|
289 |
|
290 |
// data
|
291 |
-
$users = $this->get_user_id_list( $role, $from, $to );
|
292 |
foreach ( $users as $user ) {
|
293 |
$userdata = get_userdata( $user );
|
294 |
|
@@ -377,8 +383,8 @@ class ACUI_Exporter{
|
|
377 |
return apply_filters( 'acui_export_get_user_meta_keys', $meta_keys );
|
378 |
}
|
379 |
|
380 |
-
function get_user_id_list( $role, $from, $to ){
|
381 |
-
$args = array( 'fields' => array( 'ID' ) );
|
382 |
|
383 |
if( !empty( $role ) )
|
384 |
$args['role'] = $role;
|
@@ -396,6 +402,18 @@ class ACUI_Exporter{
|
|
396 |
$args['date_query'] = $date_query;
|
397 |
}
|
398 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
399 |
$users = get_users( $args );
|
400 |
$list = array();
|
401 |
|
4 |
class ACUI_Exporter{
|
5 |
private $path_csv;
|
6 |
private $user_data;
|
7 |
+
private $accepted_order_by;
|
8 |
+
private $woocommerce_default_user_meta_keys;
|
9 |
+
private $other_non_date_keys;
|
10 |
|
11 |
function __construct(){
|
12 |
$upload_dir = wp_upload_dir();
|
13 |
|
14 |
$this->path_csv = $upload_dir['basedir'] . "/export-users.csv";
|
15 |
$this->user_data = array( "user_login", "user_email", "source_user_id", "user_pass", "user_nicename", "user_url", "user_registered", "display_name" );
|
16 |
+
$this->accepted_order_by = array( 'ID', 'display_name', 'name', 'user_name', 'login', 'user_login', 'nicename', 'user_nicename', 'email', 'user_email', 'url', 'user_url', 'registered', 'user_registered', 'post_count' );
|
17 |
$this->woocommerce_default_user_meta_keys = array( 'billing_first_name', 'billing_last_name', 'billing_email', 'billing_phone', 'billing_country', 'billing_address_1', 'billing_city', 'billing_state', 'billing_postcode', 'shipping_first_name', 'shipping_last_name', 'shipping_country', 'shipping_address_1', 'shipping_address_2', 'shipping_city', 'shipping_state', 'shipping_postcode' );
|
18 |
$this->other_non_date_keys = array( 'shipping_phone' );
|
19 |
|
245 |
$double_encapsulate_serialized_values = isset( $_POST['double_encapsulate_serialized_values'] ) && !empty( $_POST['double_encapsulate_serialized_values'] );
|
246 |
$filtered_columns = ( isset( $_POST['columns'] ) && !empty( $_POST['columns'] ) ) ? $_POST['columns'] : array();
|
247 |
$filtered_columns = $this->manage_filtered_columns( $filtered_columns );
|
248 |
+
$orderby = ( isset( $_POST['orderby'] ) && !empty( $_POST['orderby'] ) ) ? sanitize_text_field( $_POST['orderby'] ) : '';
|
249 |
+
$order = ( isset( $_POST['order'] ) && !empty( $_POST['order'] ) ) ? sanitize_text_field( $_POST['order'] ) : '';
|
250 |
|
251 |
switch ( $delimiter ) {
|
252 |
case 'COMMA':
|
294 |
$row = array();
|
295 |
|
296 |
// data
|
297 |
+
$users = $this->get_user_id_list( $role, $from, $to, $orderby, $order );
|
298 |
foreach ( $users as $user ) {
|
299 |
$userdata = get_userdata( $user );
|
300 |
|
383 |
return apply_filters( 'acui_export_get_user_meta_keys', $meta_keys );
|
384 |
}
|
385 |
|
386 |
+
function get_user_id_list( $role, $from, $to, $orderby = '', $order = 'ASC' ){
|
387 |
+
$args = array( 'fields' => array( 'ID' ), 'order' => $order );
|
388 |
|
389 |
if( !empty( $role ) )
|
390 |
$args['role'] = $role;
|
402 |
$args['date_query'] = $date_query;
|
403 |
}
|
404 |
|
405 |
+
if( !empty( $orderby ) ){
|
406 |
+
if( in_array( $orderby, $this->accepted_order_by ) )
|
407 |
+
$args['orderby'] = $orderby;
|
408 |
+
else{
|
409 |
+
$args['orderby'] = "meta_value";
|
410 |
+
$args['meta_key'] = $orderby;
|
411 |
+
}
|
412 |
+
|
413 |
+
if( !empty( $order ) )
|
414 |
+
$args['order'] = $order;
|
415 |
+
}
|
416 |
+
|
417 |
$users = get_users( $args );
|
418 |
$list = array();
|
419 |
|
classes/frontend.php
CHANGED
@@ -273,6 +273,31 @@ class ACUI_Frontend{
|
|
273 |
</td>
|
274 |
</tr>
|
275 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
276 |
</tbody>
|
277 |
</table>
|
278 |
|
@@ -449,7 +474,7 @@ class ACUI_Frontend{
|
|
449 |
}
|
450 |
|
451 |
function shortcode_export( $atts ) {
|
452 |
-
$atts = shortcode_atts( array( 'role' => '', 'from' => '', 'to' => '', 'delimiter' => '', 'order-alphabetically' => '', 'columns' => '' ), $atts );
|
453 |
|
454 |
ob_start();
|
455 |
|
273 |
</td>
|
274 |
</tr>
|
275 |
|
276 |
+
<tr class="form-field">
|
277 |
+
<th scope="row"><label for=""><?php _e( 'Attribute orderby', 'import-users-from-csv-with-meta' ); ?></label></th>
|
278 |
+
<td><?php _e( 'You can use orderby attribute to set the order in which users would be exported. You can use some of the next fields or a meta_key:', 'import-users-from-csv-with-meta' ); ?>
|
279 |
+
<ul style="list-style:disc outside none;margin-left:2em;">
|
280 |
+
<li><strong>ID</strong>: <?php _e( 'Order by user id', 'import-users-from-csv-with-meta' ); ?></li>
|
281 |
+
<li><strong>display_name</strong>: <?php _e( 'Order by user display name', 'import-users-from-csv-with-meta' ); ?></li>
|
282 |
+
<li><strong>name</strong> or <strong>user_name</strong>: <?php _e( 'Order by user name', 'import-users-from-csv-with-meta' ); ?></li>
|
283 |
+
<li><strong>login</strong> or <strong>user_login</strong>: <?php _e( 'Order by user login', 'import-users-from-csv-with-meta' ); ?></li>
|
284 |
+
<li><strong>nicename</strong> or <strong>user_nicename</strong>: <?php _e( 'Order by user nicename', 'import-users-from-csv-with-meta' ); ?></li>
|
285 |
+
<li><strong>email</strong> or <strong>user_email</strong>: <?php _e( 'Order by user email', 'import-users-from-csv-with-meta' ); ?></li>
|
286 |
+
<li><strong>url</strong> or <strong>user_url</strong>: <?php _e( 'Order by user url', 'import-users-from-csv-with-meta' ); ?></li>
|
287 |
+
<li><strong>registered</strong> or <strong>user_registered</strong>: <?php _e( 'Order by user registered date', 'import-users-from-csv-with-meta' ); ?></li>
|
288 |
+
<li><strong>post_count</strong>: <?php _e( 'Order by user post count', 'import-users-from-csv-with-meta' ); ?></li>
|
289 |
+
<li><strong><?php _e( 'Any meta_key', 'import-users-from-csv-with-meta' ); ?></strong>: <?php _e( 'Order by user meta value', 'import-users-from-csv-with-meta' ); ?></li>
|
290 |
+
</ul>
|
291 |
+
<?php _e( 'For example', 'import-users-from-csv-with-meta' ); ?> <pre style="display: inline-block;">[export-users orderby="user_email"]</pre>
|
292 |
+
</td>
|
293 |
+
</tr>
|
294 |
+
|
295 |
+
<tr class="form-field">
|
296 |
+
<th scope="row"><label for=""><?php _e( 'Attribute order', 'import-users-from-csv-with-meta' ); ?></label></th>
|
297 |
+
<td><?php _e( 'If you use orderby attrbute you can also use order attribute that designates the ascending or descending order of the "orderby" parameter, values can be "asc" or "desc", for example', 'import-users-from-csv-with-meta' ); ?> <pre>[export-users orderby="display_name" order="asc"]</pre>
|
298 |
+
</td>
|
299 |
+
</tr>
|
300 |
+
|
301 |
</tbody>
|
302 |
</table>
|
303 |
|
474 |
}
|
475 |
|
476 |
function shortcode_export( $atts ) {
|
477 |
+
$atts = shortcode_atts( array( 'role' => '', 'from' => '', 'to' => '', 'delimiter' => '', 'order-alphabetically' => '', 'columns' => '', 'orderby' => '', 'order' => '' ), $atts );
|
478 |
|
479 |
ob_start();
|
480 |
|
import-users-from-csv-with-meta.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
Plugin Name: Import and export users and customers
|
4 |
Plugin URI: https://www.codection.com
|
5 |
Description: Using this plugin you will be able to import and export users or customers choosing many options and interacting with lots of other plugins
|
6 |
-
Version: 1.17.
|
7 |
Author: codection
|
8 |
Author URI: https://codection.com
|
9 |
License: GPL2
|
3 |
Plugin Name: Import and export users and customers
|
4 |
Plugin URI: https://www.codection.com
|
5 |
Description: Using this plugin you will be able to import and export users or customers choosing many options and interacting with lots of other plugins
|
6 |
+
Version: 1.17.9
|
7 |
Author: codection
|
8 |
Author URI: https://codection.com
|
9 |
License: GPL2
|
readme.txt
CHANGED
@@ -103,6 +103,9 @@ Plugin will automatically detect:
|
|
103 |
|
104 |
== Changelog ==
|
105 |
|
|
|
|
|
|
|
106 |
= 1.17.8.4 =
|
107 |
* Bug fixed in WP User Manager addon
|
108 |
|
103 |
|
104 |
== Changelog ==
|
105 |
|
106 |
+
= 1.17.9 =
|
107 |
+
* Export now can be ordered using an attribute in the shortcode, attributes are orderby and order, how to use them it is explained there
|
108 |
+
|
109 |
= 1.17.8.4 =
|
110 |
* Bug fixed in WP User Manager addon
|
111 |
|