Import users from CSV with meta - Version 1.11.3.7

Version Description

  • Fixes and improvements thanks to @malcolm-oph
Download this release

Release Info

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

Code changes from version 1.11.3.6 to 1.11.3.7

import-users-from-csv-with-meta.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Import users from CSV with meta
4
  Plugin URI: https://www.codection.com
5
  Description: This plugins allows to import users using CSV files to WP database automatically
6
- Version: 1.11.3.6
7
  Author: codection
8
  Author URI: https://codection.com
9
  License: GPL2
3
  Plugin Name: Import users from CSV with meta
4
  Plugin URI: https://www.codection.com
5
  Description: This plugins allows to import users using CSV files to WP database automatically
6
+ Version: 1.11.3.7
7
  Author: codection
8
  Author URI: https://codection.com
9
  License: GPL2
importer.php CHANGED
@@ -236,6 +236,10 @@ function acui_import_users( $file, $form_data, $attach_id = 0, $is_cron = false,
236
  $created = true;
237
  }
238
  }
 
 
 
 
239
  elseif( username_exists( $username ) ){ // if user exists, we take his ID by login, we will update his mail if it has changed
240
  if( $update_existing_users == 'no' ){
241
  continue;
@@ -320,6 +324,30 @@ function acui_import_users( $file, $form_data, $attach_id = 0, $is_cron = false,
320
  $user_object->add_role( $role );
321
  }
322
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
323
  }
324
  }
325
  }
236
  $created = true;
237
  }
238
  }
239
+ elseif( !empty( $email ) && ( ( sanitize_email( $email ) == '' ) ) ){ // if email is invalid
240
+ $problematic_row = true;
241
+ $data[0] = __('Invalid EMail','import-users-from-csv-with-meta')." ($email)";
242
+ }
243
  elseif( username_exists( $username ) ){ // if user exists, we take his ID by login, we will update his mail if it has changed
244
  if( $update_existing_users == 'no' ){
245
  continue;
324
  $user_object->add_role( $role );
325
  }
326
  }
327
+
328
+ $invalid_roles = array();
329
+ if( !empty( $role ) ){
330
+ if( !is_array( $role ) )
331
+ $role[] = $role;
332
+
333
+ foreach ($role as $single_role) {
334
+ $single_role = strtolower($single_role);
335
+ if( get_role( $single_role ) ){
336
+ $user_object->add_role( $single_role );
337
+ }
338
+ else{
339
+ $invalid_roles[] = trim( $single_role );
340
+ }
341
+ }
342
+ }
343
+
344
+ if ( !empty( $invalid_roles ) ){
345
+ $problematic_row = true;
346
+ if( count( $invalid_roles ) == 1 )
347
+ $data[0] = __('Invalid role','import-users-from-csv-with-meta').' (' . reset( $invalid_roles ) . ')';
348
+ else
349
+ $data[0] = __('Invalid roles','import-users-from-csv-with-meta').' (' . implode( ', ', $invalid_roles ) . ')';
350
+ }
351
  }
352
  }
353
  }
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: carazo, hornero
3
  Donate link: http://paypal.me/codection
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: 4.9.7
7
- Stable tag: 1.11.3.6
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -71,6 +71,9 @@ Plugin will automatically detect:
71
 
72
  == Changelog ==
73
 
 
 
 
74
  = 1.11.3.6 =
75
  * Role import working in cron jobs
76
 
3
  Donate link: http://paypal.me/codection
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: 4.9.8
7
+ Stable tag: 1.11.3.7
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
71
 
72
  == Changelog ==
73
 
74
+ = 1.11.3.7 =
75
+ * Fixes and improvements thanks to @malcolm-oph
76
+
77
  = 1.11.3.6 =
78
  * Role import working in cron jobs
79