Import users from CSV with meta - Version 1.19.3

Version Description

  • Now you can choose to delete roles when importing (creating or updating) users
  • Fixed problem with select2.js in homepage tab
Download this release

Release Info

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

Code changes from version 1.19.2.7 to 1.19.3

classes/doc.php CHANGED
@@ -47,6 +47,7 @@ class ACUI_Doc{
47
  <li><?php _e( "If you <strong>don't create a column for roles</strong>: roles would be chosen from the 'Default role' field in import screen.", 'import-users-from-csv-with-meta' ); ?></li>
48
  <li><?php _e( "If you <strong>create a column called 'role'</strong>: if cell is empty, roles would be chosen from 'Default role' field in import screen; if cell has a value, it will be used as role, if this role doesn't exist the default one would be used", 'import-users-from-csv-with-meta' ); ?></li>
49
  <li><?php _e( "Multiple roles can be imported creating <strong>a list of roles</strong> using commas to separate values.", 'import-users-from-csv-with-meta' ); ?></li>
 
50
  </ul>
51
  <em><?php _e( "Notice: If the default new role is administrator in WordPress settings, role will not be set during a CSV file import with this plugin. Check it if all users are being imported as administrators and you have set another role in this plugin.", 'import-users-from-csv-with-meta' ); ?></em>
52
  </td>
47
  <li><?php _e( "If you <strong>don't create a column for roles</strong>: roles would be chosen from the 'Default role' field in import screen.", 'import-users-from-csv-with-meta' ); ?></li>
48
  <li><?php _e( "If you <strong>create a column called 'role'</strong>: if cell is empty, roles would be chosen from 'Default role' field in import screen; if cell has a value, it will be used as role, if this role doesn't exist the default one would be used", 'import-users-from-csv-with-meta' ); ?></li>
49
  <li><?php _e( "Multiple roles can be imported creating <strong>a list of roles</strong> using commas to separate values.", 'import-users-from-csv-with-meta' ); ?></li>
50
+ <li><?php _e( "If you choose <strong>no role</strong> checkbox or write <strong>no_role</strong> in the column role, the users created or updated won't have any role assigned.", 'import-users-from-csv-with-meta' ); ?></li>
51
  </ul>
52
  <em><?php _e( "Notice: If the default new role is administrator in WordPress settings, role will not be set during a CSV file import with this plugin. Check it if all users are being imported as administrators and you have set another role in this plugin.", 'import-users-from-csv-with-meta' ); ?></em>
53
  </td>
classes/helper.php CHANGED
@@ -38,7 +38,7 @@ class ACUI_Helper{
38
  return $roles;
39
  }
40
 
41
- static function get_editable_roles() {
42
  global $wp_roles;
43
 
44
  $all_roles = $wp_roles->roles;
@@ -47,6 +47,9 @@ class ACUI_Helper{
47
 
48
  foreach ($editable_roles as $key => $editable_role)
49
  $list_editable_roles[$key] = translate_user_role( $editable_role["name"] );
 
 
 
50
 
51
  return $list_editable_roles;
52
  }
38
  return $roles;
39
  }
40
 
41
+ static function get_editable_roles( $include_no_role = true ){
42
  global $wp_roles;
43
 
44
  $all_roles = $wp_roles->roles;
47
 
48
  foreach ($editable_roles as $key => $editable_role)
49
  $list_editable_roles[$key] = translate_user_role( $editable_role["name"] );
50
+
51
+ if( $include_no_role )
52
+ $list_editable_roles['no_role'] = __( 'No role', 'import-users-from-csv-with-meta' );
53
 
54
  return $list_editable_roles;
55
  }
classes/homepage.php CHANGED
@@ -15,9 +15,9 @@ class ACUI_Homepage{
15
  }
16
 
17
  function load_scripts( $hook ){
18
- if( $hook != 'tools_page_acui' || isset( $_GET['tab'] ) )
19
  return;
20
-
21
  wp_enqueue_style( 'select2-css', '//cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/css/select2.min.css' );
22
  wp_enqueue_script( 'select2-js', '//cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/js/select2.min.js' );
23
  }
@@ -298,6 +298,26 @@ class ACUI_Homepage{
298
  }
299
  } );
300
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
301
  $( '#delete_users' ).on( 'click', function() {
302
  check_delete_users_checked();
303
  });
15
  }
16
 
17
  function load_scripts( $hook ){
18
+ if( $hook != 'tools_page_acui' || ( isset( $_GET['tab'] ) && $_GET['tab'] != 'homepage' ) )
19
  return;
20
+
21
  wp_enqueue_style( 'select2-css', '//cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/css/select2.min.css' );
22
  wp_enqueue_script( 'select2-js', '//cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/js/select2.min.js' );
23
  }
298
  }
299
  } );
300
 
301
+ $( '.acui-checkbox.roles[value="no_role"]' ).click( function(){
302
+ var checked = $( this ).is(':checked');
303
+ if( checked ) {
304
+ if( !confirm( '<?php _e( 'Are you sure you want to disables roles from this users?', 'import-users-from-csv-with-meta' ); ?>' ) ){
305
+ $( this ).removeAttr( 'checked' );
306
+ return;
307
+ }
308
+ else{
309
+ $( '.acui-checkbox.roles' ).not( '.acui-checkbox.roles[value="no_role"]' ).each( function(){
310
+ $( this ).removeAttr( 'checked' );
311
+ } )
312
+ }
313
+ }
314
+ } );
315
+
316
+ $( '.acui-checkbox.roles' ).click( function(){
317
+ if( $( this ).val() != 'no_role' && $( this ).val() != '' )
318
+ $( '.acui-checkbox.roles[value="no_role"]' ).removeAttr( 'checked' );
319
+ } );
320
+
321
  $( '#delete_users' ).on( 'click', function() {
322
  check_delete_users_checked();
323
  });
classes/import.php CHANGED
@@ -393,20 +393,24 @@ class ACUI_Import{
393
  $role = $roles_cells;
394
  }
395
 
396
- if( ( !empty( $role ) || is_array( $role ) && empty( $role[0] ) ) && !empty( array_diff( $role, $all_roles ) ) && $update_roles_existing_users != 'no' ){
397
- if( is_array( $role ) && empty( $role[0] ) )
398
- $errors[] = $acui_helper->new_error( $row, $errors_totals, sprintf( __( 'If you are upgrading roles, you must choose at least one role', 'import-users-from-csv-with-meta' ), implode( ', ', $role ) ) );
399
- else
400
- $errors[] = $acui_helper->new_error( $row, $errors_totals, sprintf( __( 'Some of the next roles "%s" does not exists', 'import-users-from-csv-with-meta' ), implode( ', ', $role ) ) );
401
- continue;
402
- }
403
-
404
- if ( ( !empty( $role ) || is_array( $role ) && empty( $role[0] ) ) && !empty( array_diff( $role, $editable_roles ) && $update_roles_existing_users != 'no' ) ){ // users only are able to import users with a role they are allowed to edit
405
- $errors[] = $acui_helper->new_error( $row, $errors_totals, sprintf( __( 'You do not have permission to assign some of the next roles "%s"', 'import-users-from-csv-with-meta' ), implode( ', ', $role ) ) );
406
- $created = false;
407
- continue;
 
 
 
 
408
  }
409
-
410
  if( !empty( $email ) && ( ( sanitize_email( $email ) == '' ) ) ){ // if email is invalid
411
  $errors[] = $acui_helper->new_error( $row, $errors_totals, sprintf( __( 'Invalid email "%s"', 'import-users-from-csv-with-meta' ), $email ) );
412
  $data[0] = __('Invalid EMail','import-users-from-csv-with-meta')." ($email)";
@@ -569,8 +573,8 @@ class ACUI_Import{
569
  $user_object->remove_role( $default_role );
570
  }
571
  }
572
-
573
- if( $update_roles_existing_users == 'yes' || $update_roles_existing_users == 'yes_no_override' || $created ){
574
  if( !empty( $role ) ){
575
  if( is_array( $role ) ){
576
  foreach ($role as $single_role) {
@@ -598,7 +602,7 @@ class ACUI_Import{
598
  else{
599
  $invalid_roles[] = trim( $single_role );
600
  }
601
- }
602
  }
603
 
604
  if ( !empty( $invalid_roles ) ){
393
  $role = $roles_cells;
394
  }
395
 
396
+ $no_role = ( $role == 'no_role' ) || in_array( 'no_role', $role );
397
+
398
+ if( !$no_role ){
399
+ if( ( !empty( $role ) || is_array( $role ) && empty( $role[0] ) ) && !empty( array_diff( $role, $all_roles ) ) && $update_roles_existing_users != 'no' ){
400
+ if( is_array( $role ) && empty( $role[0] ) )
401
+ $errors[] = $acui_helper->new_error( $row, $errors_totals, sprintf( __( 'If you are upgrading roles, you must choose at least one role', 'import-users-from-csv-with-meta' ), implode( ', ', $role ) ) );
402
+ else
403
+ $errors[] = $acui_helper->new_error( $row, $errors_totals, sprintf( __( 'Some of the next roles "%s" does not exists', 'import-users-from-csv-with-meta' ), implode( ', ', $role ) ) );
404
+ continue;
405
+ }
406
+
407
+ if ( ( !empty( $role ) || is_array( $role ) && empty( $role[0] ) ) && !empty( array_diff( $role, $editable_roles ) && $update_roles_existing_users != 'no' ) ){ // users only are able to import users with a role they are allowed to edit
408
+ $errors[] = $acui_helper->new_error( $row, $errors_totals, sprintf( __( 'You do not have permission to assign some of the next roles "%s"', 'import-users-from-csv-with-meta' ), implode( ', ', $role ) ) );
409
+ $created = false;
410
+ continue;
411
+ }
412
  }
413
+
414
  if( !empty( $email ) && ( ( sanitize_email( $email ) == '' ) ) ){ // if email is invalid
415
  $errors[] = $acui_helper->new_error( $row, $errors_totals, sprintf( __( 'Invalid email "%s"', 'import-users-from-csv-with-meta' ), $email ) );
416
  $data[0] = __('Invalid EMail','import-users-from-csv-with-meta')." ($email)";
573
  $user_object->remove_role( $default_role );
574
  }
575
  }
576
+
577
+ if( !$no_role && ( $update_roles_existing_users == 'yes' || $update_roles_existing_users == 'yes_no_override' || $created ) ){
578
  if( !empty( $role ) ){
579
  if( is_array( $role ) ){
580
  foreach ($role as $single_role) {
602
  else{
603
  $invalid_roles[] = trim( $single_role );
604
  }
605
+ }
606
  }
607
 
608
  if ( !empty( $invalid_roles ) ){
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.19.2.7
7
  Author: codection
8
  Author URI: https://codection.com
9
  License: GPL2
@@ -14,7 +14,7 @@ Domain Path: /languages
14
  if ( ! defined( 'ABSPATH' ) )
15
  exit;
16
 
17
- define( 'ACUI_VERSION', '1.19.2.7' );
18
 
19
  class ImportExportUsersCustomers{
20
  var $file;
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.19.3
7
  Author: codection
8
  Author URI: https://codection.com
9
  License: GPL2
14
  if ( ! defined( 'ABSPATH' ) )
15
  exit;
16
 
17
+ define( 'ACUI_VERSION', '1.19.3' );
18
 
19
  class ImportExportUsersCustomers{
20
  var $file;
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: 6.0
7
- Stable tag: 1.19.2.7
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -107,6 +107,10 @@ Plugin will automatically detect:
107
 
108
  == Changelog ==
109
 
 
 
 
 
110
  = 1.19.2.7 =
111
  * Fixed issue in BuddyPress integration when exporting data
112
 
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: 6.0
7
+ Stable tag: 1.19.3
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
107
 
108
  == Changelog ==
109
 
110
+ = 1.19.3 =
111
+ * Now you can choose to delete roles when importing (creating or updating) users
112
+ * Fixed problem with select2.js in homepage tab
113
+
114
  = 1.19.2.7 =
115
  * Fixed issue in BuddyPress integration when exporting data
116