Import users from CSV with meta - Version 1.17.2

Version Description

  • New addon included for WPML
  • Email templates are being sent translated if you use the "locale" column in your CSV, so every user will receive the email translated in their own langauge
Download this release

Release Info

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

Code changes from version 1.17.1.5 to 1.17.2

classes/email-options.php CHANGED
@@ -183,7 +183,7 @@ class ACUI_Email_Options{
183
  <?php
184
  }
185
 
186
- public static function send_email( $user_object, $positions = array(), $headers = array(), $data = array(), $created = false, $password = '' ){
187
  $acui_helper = new ACUI_Helper();
188
 
189
  $key = get_password_reset_key( $user_object );
@@ -193,8 +193,8 @@ class ACUI_Email_Options{
193
  $user_login= $user_object->user_login;
194
  $user_email = $user_object->user_email;
195
 
196
- $body = get_option( "acui_mail_body" );
197
- $subject = get_option( "acui_mail_subject" );
198
 
199
  $body = str_replace( "**loginurl**", wp_login_url(), $body );
200
  $body = str_replace( "**username**", $user_login, $body );
183
  <?php
184
  }
185
 
186
+ static function send_email( $user_object, $positions = array(), $headers = array(), $data = array(), $created = false, $password = '' ){
187
  $acui_helper = new ACUI_Helper();
188
 
189
  $key = get_password_reset_key( $user_object );
193
  $user_login= $user_object->user_login;
194
  $user_email = $user_object->user_email;
195
 
196
+ $body = apply_filters( 'acui_import_email_body_source', get_option( "acui_mail_body" ), $headers, $data, $created, $user_id );
197
+ $subject = apply_filters( 'acui_import_email_subject_source', get_option( "acui_mail_subject" ), $headers, $data, $created, $user_id );
198
 
199
  $body = str_replace( "**loginurl**", wp_login_url(), $body );
200
  $body = str_replace( "**username**", $user_login, $body );
classes/export.php CHANGED
@@ -234,9 +234,6 @@ class ACUI_Exporter{
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 );
234
  $row[ $key ] = self::prepare( $key, get_user_meta( $user, $key, true ), $datetime_format, $user );
235
  }
236
 
 
 
 
237
  $row = $this->maybe_fill_empty_data( $row, $user );
238
 
239
  $row = apply_filters( 'acui_export_data', $row, $user, $datetime_format, $columns, $order_fields_alphabetically );
classes/helper.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
 
3
  class ACUI_Helper{
4
- public function detect_delimiter( $file ) {
5
  $delimiters = array(
6
  ';' => 0,
7
  ',' => 0,
@@ -19,14 +19,14 @@ class ACUI_Helper{
19
  return array_search(max($delimiters), $delimiters);
20
  }
21
 
22
- public function user_id_exists( $user_id ){
23
  if ( get_userdata( $user_id ) === false )
24
  return false;
25
  else
26
  return true;
27
  }
28
 
29
- public function get_roles_by_user_id( $user_id ){
30
  $roles = array();
31
  $user = new WP_User( $user_id );
32
 
@@ -38,7 +38,7 @@ class ACUI_Helper{
38
  return $roles;
39
  }
40
 
41
- public static function get_editable_roles() {
42
  global $wp_roles;
43
 
44
  $all_roles = $wp_roles->roles;
@@ -51,7 +51,7 @@ class ACUI_Helper{
51
  return $list_editable_roles;
52
  }
53
 
54
- public static function get_errors_by_row( $errors, $row, $type = 'error' ){
55
  $errors_found = array();
56
 
57
  foreach( $errors as $error ){
@@ -63,7 +63,7 @@ class ACUI_Helper{
63
  return $errors_found;
64
  }
65
 
66
- public function string_conversion( $string ){
67
  if(!preg_match('%(?:
68
  [\xC2-\xDF][\x80-\xBF] # non-overlong 2-byte
69
  |\xE0[\xA0-\xBF][\x80-\xBF] # excluding overlongs
@@ -79,7 +79,7 @@ class ACUI_Helper{
79
  return $string;
80
  }
81
 
82
- public function get_wp_users_fields(){
83
  return array( "id", "user_email", "user_nicename", "user_url", "display_name", "nickname", "first_name", "last_name", "description", "jabber", "aim", "yim", "user_registered", "password", "user_pass", "locale", "show_admin_bar_front", "user_login" );
84
  }
85
 
@@ -95,7 +95,7 @@ class ACUI_Helper{
95
  return apply_filters( 'acui_not_meta_fields', array() );
96
  }
97
 
98
- public function get_random_unique_username( $prefix = '' ){
99
  do {
100
  $rnd_str = sprintf("%06d", mt_rand(1, 999999));
101
  } while( username_exists( $prefix . $rnd_str ) );
@@ -107,7 +107,7 @@ class ACUI_Helper{
107
  return array( 'row' => $row, 'message' => $message, 'type' => $type );
108
  }
109
 
110
- public function maybe_update_email( $user_id, $email, $password, $update_emails_existing_users ){
111
  $user_object = get_user_by( 'id', $user_id );
112
 
113
  if( $user_object->user_email == $email )
@@ -135,7 +135,7 @@ class ACUI_Helper{
135
  return $user_id;
136
  }
137
 
138
- public static function get_attachment_id_by_url( $url ) {
139
  $wp_upload_dir = wp_upload_dir();
140
  // Strip out protocols, so it doesn't fail because searching for http: in https: dir.
141
  $dir = set_url_scheme( trailingslashit( $wp_upload_dir['baseurl'] ), 'relative' );
@@ -274,7 +274,7 @@ class ACUI_Helper{
274
  <?php
275
  }
276
 
277
- public function basic_css(){
278
  ?>
279
  <style type="text/css">
280
  .wrap{
@@ -292,4 +292,13 @@ class ACUI_Helper{
292
  </style>
293
  <?php
294
  }
 
 
 
 
 
 
 
 
 
295
  }
1
  <?php
2
 
3
  class ACUI_Helper{
4
+ function detect_delimiter( $file ) {
5
  $delimiters = array(
6
  ';' => 0,
7
  ',' => 0,
19
  return array_search(max($delimiters), $delimiters);
20
  }
21
 
22
+ function user_id_exists( $user_id ){
23
  if ( get_userdata( $user_id ) === false )
24
  return false;
25
  else
26
  return true;
27
  }
28
 
29
+ function get_roles_by_user_id( $user_id ){
30
  $roles = array();
31
  $user = new WP_User( $user_id );
32
 
38
  return $roles;
39
  }
40
 
41
+ static function get_editable_roles() {
42
  global $wp_roles;
43
 
44
  $all_roles = $wp_roles->roles;
51
  return $list_editable_roles;
52
  }
53
 
54
+ static function get_errors_by_row( $errors, $row, $type = 'error' ){
55
  $errors_found = array();
56
 
57
  foreach( $errors as $error ){
63
  return $errors_found;
64
  }
65
 
66
+ function string_conversion( $string ){
67
  if(!preg_match('%(?:
68
  [\xC2-\xDF][\x80-\xBF] # non-overlong 2-byte
69
  |\xE0[\xA0-\xBF][\x80-\xBF] # excluding overlongs
79
  return $string;
80
  }
81
 
82
+ function get_wp_users_fields(){
83
  return array( "id", "user_email", "user_nicename", "user_url", "display_name", "nickname", "first_name", "last_name", "description", "jabber", "aim", "yim", "user_registered", "password", "user_pass", "locale", "show_admin_bar_front", "user_login" );
84
  }
85
 
95
  return apply_filters( 'acui_not_meta_fields', array() );
96
  }
97
 
98
+ function get_random_unique_username( $prefix = '' ){
99
  do {
100
  $rnd_str = sprintf("%06d", mt_rand(1, 999999));
101
  } while( username_exists( $prefix . $rnd_str ) );
107
  return array( 'row' => $row, 'message' => $message, 'type' => $type );
108
  }
109
 
110
+ function maybe_update_email( $user_id, $email, $password, $update_emails_existing_users ){
111
  $user_object = get_user_by( 'id', $user_id );
112
 
113
  if( $user_object->user_email == $email )
135
  return $user_id;
136
  }
137
 
138
+ static function get_attachment_id_by_url( $url ) {
139
  $wp_upload_dir = wp_upload_dir();
140
  // Strip out protocols, so it doesn't fail because searching for http: in https: dir.
141
  $dir = set_url_scheme( trailingslashit( $wp_upload_dir['baseurl'] ), 'relative' );
274
  <?php
275
  }
276
 
277
+ function basic_css(){
278
  ?>
279
  <style type="text/css">
280
  .wrap{
292
  </style>
293
  <?php
294
  }
295
+
296
+ static function get_value_from_row( $key, $headers, $row ){
297
+ $pos = array_search( $key, $headers );
298
+
299
+ if( $pos === false )
300
+ return false;
301
+
302
+ return $row[ $pos ];
303
+ }
304
  }
classes/import.php CHANGED
@@ -322,7 +322,10 @@ class ACUI_Import{
322
  $roles_cells = array( $roles_cells );
323
 
324
  array_walk( $roles_cells, 'trim' );
325
- array_walk( $roles_cells, 'strtolower' );
 
 
 
326
  $role = $roles_cells;
327
  }
328
 
322
  $roles_cells = array( $roles_cells );
323
 
324
  array_walk( $roles_cells, 'trim' );
325
+
326
+ foreach( $roles_cells as $it => $role_cell )
327
+ $roles_cells[ $it ] = strtolower( $role_cell );
328
+
329
  $role = $roles_cells;
330
  }
331
 
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.5
7
  Author: codection
8
  Author URI: https://codection.com
9
  License: GPL2
@@ -11,6 +11,7 @@ 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
  if ( ! defined( 'ABSPATH' ) )
15
  exit;
16
 
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.2
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
+
15
  if ( ! defined( 'ABSPATH' ) )
16
  exit;
17
 
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.5
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -103,6 +103,13 @@ Plugin will automatically detect:
103
 
104
  == Changelog ==
105
 
 
 
 
 
 
 
 
106
  = 1.17.1.5 =
107
  * Bugs fixed exporting users
108
 
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.2
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.2 =
107
+ * New addon included for WPML
108
+ * Email templates are being sent translated if you use the "locale" column in your CSV, so every user will receive the email translated in their own langauge
109
+
110
+ = 1.17.1.6 =
111
+ * Warning solved, it appears sometimes importing in strtolower operation over roles
112
+
113
  = 1.17.1.5 =
114
  * Bugs fixed exporting users
115