Import users from CSV with meta - Version 1.17.1.5

Version Description

  • Bugs fixed exporting users
Download this release

Release Info

Developer carazo
Plugin Icon 128x128 Import users from CSV with meta
Version 1.17.1.5
Comparing to
See all releases

Code changes from version 1.17.1.4 to 1.17.1.5

classes/export.php CHANGED
@@ -207,6 +207,8 @@ class ACUI_Exporter{
207
  $row[] = $key;
208
  }
209
 
 
 
210
  foreach ( $this->get_user_meta_keys() as $key ) {
211
  $row[] = $key;
212
  }
@@ -226,10 +228,17 @@ class ACUI_Exporter{
226
  $row[ $key ] = self::prepare( $key, $userdata->data->{$key}, $datetime_format, $user );
227
  }
228
 
 
 
229
  foreach ( $this->get_user_meta_keys() as $key ) {
230
  $row[ $key ] = self::prepare( $key, get_user_meta( $user, $key, true ), $datetime_format, $user );
231
  }
232
 
 
 
 
 
 
233
  $row = apply_filters( 'acui_export_data', $row, $user, $datetime_format, $columns, $order_fields_alphabetically );
234
 
235
  $data[] = array_values( $row );
@@ -276,8 +285,12 @@ class ACUI_Exporter{
276
  $usermeta = $wpdb->get_results( $select, ARRAY_A );
277
 
278
  foreach ($usermeta as $key => $value) {
279
- $meta_keys[] = $value["meta_key"];
280
- }
 
 
 
 
281
  return apply_filters( 'acui_export_get_user_meta_keys', $meta_keys );
282
  }
283
 
@@ -313,6 +326,20 @@ class ACUI_Exporter{
313
  function filter_key_user_id( $key ){
314
  return ( $key == 'source_user_id' ) ? 'ID' : $key;
315
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
316
  }
317
 
318
  $acui_exporter = new ACUI_Exporter();
207
  $row[] = $key;
208
  }
209
 
210
+ $row[] = "role";
211
+
212
  foreach ( $this->get_user_meta_keys() as $key ) {
213
  $row[] = $key;
214
  }
228
  $row[ $key ] = self::prepare( $key, $userdata->data->{$key}, $datetime_format, $user );
229
  }
230
 
231
+ $row[] = $this->get_role( $user );
232
+
233
  foreach ( $this->get_user_meta_keys() as $key ) {
234
  $row[ $key ] = self::prepare( $key, get_user_meta( $user, $key, true ), $datetime_format, $user );
235
  }
236
 
237
+ $row['user_login'] = '';
238
+ $row['user_email'] = '';
239
+
240
+ $row = $this->maybe_fill_empty_data( $row, $user );
241
+
242
  $row = apply_filters( 'acui_export_data', $row, $user, $datetime_format, $columns, $order_fields_alphabetically );
243
 
244
  $data[] = array_values( $row );
285
  $usermeta = $wpdb->get_results( $select, ARRAY_A );
286
 
287
  foreach ($usermeta as $key => $value) {
288
+ if( $value["meta_key"] == 'role' )
289
+ continue;
290
+
291
+ $meta_keys[] = $value["meta_key"];
292
+ }
293
+
294
  return apply_filters( 'acui_export_get_user_meta_keys', $meta_keys );
295
  }
296
 
326
  function filter_key_user_id( $key ){
327
  return ( $key == 'source_user_id' ) ? 'ID' : $key;
328
  }
329
+
330
+ function maybe_fill_empty_data( $row, $user_id ){
331
+ if( empty( $row['user_login'] ) || empty( $row['user_email'] ) ){
332
+ $user = new WP_User( $user_id );
333
+
334
+ if( $user->ID == 0 )
335
+ return $row;
336
+
337
+ $row['user_login'] = $user->user_login;
338
+ $row['user_email'] = $user->user_email;
339
+ }
340
+
341
+ return $row;
342
+ }
343
  }
344
 
345
  $acui_exporter = new ACUI_Exporter();
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.1.4
7
  Author: codection
8
  Author URI: https://codection.com
9
  License: GPL2
@@ -11,7 +11,6 @@ License URI: https://www.gnu.org/licenses/gpl-2.0.html
11
  Text Domain: import-users-from-csv-with-meta
12
  Domain Path: /languages
13
  */
14
-
15
  if ( ! defined( 'ABSPATH' ) )
16
  exit;
17
 
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.1.5
7
  Author: codection
8
  Author URI: https://codection.com
9
  License: GPL2
11
  Text Domain: import-users-from-csv-with-meta
12
  Domain Path: /languages
13
  */
 
14
  if ( ! defined( 'ABSPATH' ) )
15
  exit;
16
 
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://codection.com/go/donate-import-users-from-csv-with-meta/
4
  Tags: csv, import, importer, meta data, meta, user, users, user meta, editor, profile, custom, fields, delimiter, update, insert
5
  Requires at least: 3.4
6
  Tested up to: 5.6
7
- Stable tag: 1.17.1.4
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -103,6 +103,9 @@ Plugin will automatically detect:
103
 
104
  == Changelog ==
105
 
 
 
 
106
  = 1.17.1.4 =
107
  * Roles are always managed as small letters to minimize problems writing them
108
  * Fixed bug exporting metadata that are objects
4
  Tags: csv, import, importer, meta data, meta, user, users, user meta, editor, profile, custom, fields, delimiter, update, insert
5
  Requires at least: 3.4
6
  Tested up to: 5.6
7
+ Stable tag: 1.17.1.5
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
103
 
104
  == Changelog ==
105
 
106
+ = 1.17.1.5 =
107
+ * Bugs fixed exporting users
108
+
109
  = 1.17.1.4 =
110
  * Roles are always managed as small letters to minimize problems writing them
111
  * Fixed bug exporting metadata that are objects