Import users from CSV with meta - Version 1.15.6.1

Version Description

  • ACF addon now append values instead of replacing it
  • Created a new variable for managing data that should not be updated using the standard WordPress function
Download this release

Release Info

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

Code changes from version 1.15.6 to 1.15.6.1

addons/advanced-custom-fields.php CHANGED
@@ -9,6 +9,7 @@ if( !is_plugin_active( 'advanced-custom-fields-pro/acf.php' ) && !is_plugin_acti
9
  class ACUI_ACF{
10
  function __construct(){
11
  add_filter( 'acui_restricted_fields', array( $this, 'restricted_fields' ), 10, 1 );
 
12
  add_action( 'acui_documentation_after_plugins_activated', array( $this, 'documentation' ) );
13
  add_action( 'post_acui_import_single_user', array( $this, 'import' ), 10, 3 );
14
  }
@@ -63,6 +64,12 @@ class ACUI_ACF{
63
  }
64
  }
65
 
 
 
 
 
 
 
66
  update_field( $key, $data, "user_" . $user_id );
67
  }
68
  }
@@ -94,8 +101,11 @@ class ACUI_ACF{
94
  $fields = $this->get_user_fields();
95
  $fields_keys = array();
96
 
97
- foreach ( $this->get_user_fields() as $group => $fields ){
98
- foreach ( $fields as $field ){
 
 
 
99
  $fields_keys[] = $field['name'];
100
  }
101
  }
@@ -107,8 +117,11 @@ class ACUI_ACF{
107
  $fields = $this->get_user_fields();
108
  $fields_keys = array();
109
 
110
- foreach ( $this->get_user_fields() as $group => $fields ){
111
- foreach ( $fields as $field ){
 
 
 
112
  $fields_keys[ $field['name'] ] = $field['type'];
113
  }
114
  }
9
  class ACUI_ACF{
10
  function __construct(){
11
  add_filter( 'acui_restricted_fields', array( $this, 'restricted_fields' ), 10, 1 );
12
+ add_filter( 'acui_not_meta_fields', array( $this, 'restricted_fields' ), 10, 1 );
13
  add_action( 'acui_documentation_after_plugins_activated', array( $this, 'documentation' ) );
14
  add_action( 'post_acui_import_single_user', array( $this, 'import' ), 10, 3 );
15
  }
64
  }
65
  }
66
 
67
+ $preexisting_values = get_field( $key, "user_" . $user_id );
68
+ if( !empty( $preexisting_values ) ){
69
+ $data = array_unique( array_merge( $preexisting_values, $data ) );
70
+ $data = array_filter( $data, function( $value ) { return !is_null( $value ) && $value !== '' && $value != 0; } );
71
+ }
72
+
73
  update_field( $key, $data, "user_" . $user_id );
74
  }
75
  }
101
  $fields = $this->get_user_fields();
102
  $fields_keys = array();
103
 
104
+ if( empty( $fields ) )
105
+ return array();
106
+
107
+ foreach ( $fields as $group => $fields_of_group ){
108
+ foreach ( $fields_of_group as $field ){
109
  $fields_keys[] = $field['name'];
110
  }
111
  }
117
  $fields = $this->get_user_fields();
118
  $fields_keys = array();
119
 
120
+ if( empty( $fields ) )
121
+ return array();
122
+
123
+ foreach ( $fields as $group => $fields_of_group ){
124
+ foreach ( $fields_of_group as $field ){
125
  $fields_keys[ $field['name'] ] = $field['type'];
126
  }
127
  }
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.15.6
7
  Author: codection
8
  Author URI: https://codection.com
9
  License: GPL2
@@ -165,6 +165,10 @@ function acui_get_restricted_fields(){
165
  return apply_filters( 'acui_restricted_fields', $acui_restricted_fields );
166
  }
167
 
 
 
 
 
168
  function acui_menu() {
169
  add_submenu_page( 'tools.php', __( 'Import and export users and customers', 'import-users-from-csv-with-meta' ), __( 'Import and export users and customers', 'import-users-from-csv-with-meta' ), 'create_users', 'acui', 'acui_options' );
170
  }
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.15.6.1
7
  Author: codection
8
  Author URI: https://codection.com
9
  License: GPL2
165
  return apply_filters( 'acui_restricted_fields', $acui_restricted_fields );
166
  }
167
 
168
+ function acui_get_not_meta_fields(){
169
+ return apply_filters( 'acui_not_meta_fields', array() );
170
+ }
171
+
172
  function acui_menu() {
173
  add_submenu_page( 'tools.php', __( 'Import and export users and customers', 'import-users-from-csv-with-meta' ), __( 'Import and export users and customers', 'import-users-from-csv-with-meta' ), 'create_users', 'acui', 'acui_options' );
174
  }
importer.php CHANGED
@@ -12,6 +12,7 @@ function acui_import_users( $file, $form_data, $attach_id = 0, $is_cron = false,
12
 
13
  global $wpdb;
14
  $wp_users_fields = acui_get_wp_users_fields();
 
15
  $acui_restricted_fields = acui_get_restricted_fields();
16
 
17
  if( is_plugin_active( 'wp-access-areas/wp-access-areas.php' ) ){
@@ -415,14 +416,17 @@ function acui_import_users( $file, $form_data, $attach_id = 0, $is_cron = false,
415
  }
416
 
417
  // WP Members activation
418
- if( $activate_users_wp_members == "activate" )
419
  update_user_meta( $user_id, "active", true );
 
420
 
421
  // New User Approve
422
- if( $approve_users_new_user_approve == "approve" )
423
  update_user_meta( $user_id, "pw_user_status", "approved" );
424
- else
 
425
  update_user_meta( $user_id, "pending", true );
 
426
 
427
  if( $columns > 2 ){
428
  for( $i = 2 ; $i < $columns; $i++ ):
@@ -517,6 +521,9 @@ function acui_import_users( $file, $form_data, $attach_id = 0, $is_cron = false,
517
  elseif( $headers[ $i ] == 'bp_group_role' ){
518
  continue;
519
  }
 
 
 
520
  else{ // wp_usermeta data
521
  if( $data[ $i ] === '' ){
522
  if( $empty_cell_action == "delete" )
12
 
13
  global $wpdb;
14
  $wp_users_fields = acui_get_wp_users_fields();
15
+ $acui_not_meta_fields = acui_get_not_meta_fields();
16
  $acui_restricted_fields = acui_get_restricted_fields();
17
 
18
  if( is_plugin_active( 'wp-access-areas/wp-access-areas.php' ) ){
416
  }
417
 
418
  // WP Members activation
419
+ if( $activate_users_wp_members == "activate" ){
420
  update_user_meta( $user_id, "active", true );
421
+ }
422
 
423
  // New User Approve
424
+ if( $approve_users_new_user_approve == "approve" ){
425
  update_user_meta( $user_id, "pw_user_status", "approved" );
426
+ }
427
+ else{
428
  update_user_meta( $user_id, "pending", true );
429
+ }
430
 
431
  if( $columns > 2 ){
432
  for( $i = 2 ; $i < $columns; $i++ ):
521
  elseif( $headers[ $i ] == 'bp_group_role' ){
522
  continue;
523
  }
524
+ elseif( in_array( $headers[ $i ], $acui_not_meta_fields ) ){
525
+ continue;
526
+ }
527
  else{ // wp_usermeta data
528
  if( $data[ $i ] === '' ){
529
  if( $empty_cell_action == "delete" )
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.4.1
7
- Stable tag: 1.15.6
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -99,9 +99,12 @@ Plugin will automatically detect:
99
 
100
  == Changelog ==
101
 
 
 
 
 
102
  = 1.15.6 =
103
  * ACF compatibility included
104
- * BuddyPress member_type import included thanks to @morenolq (https://wordpress.org/support/topic/import-user-member-type-as-csv-field/)
105
 
106
  = 1.15.5.13 =
107
  * var_dump forgotten
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.4.1
7
+ Stable tag: 1.15.6.1
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
99
 
100
  == Changelog ==
101
 
102
+ = 1.15.6.1 =
103
+ * ACF addon now append values instead of replacing it
104
+ * Created a new variable for managing data that should not be updated using the standard WordPress function
105
+
106
  = 1.15.6 =
107
  * ACF compatibility included
 
108
 
109
  = 1.15.5.13 =
110
  * var_dump forgotten