Import users from CSV with meta - Version 1.10.6.9

Version Description

  • Thanks to Peri Lane from Apis Productions you can now import roles from CSV. Read documentation to see the way to work.
Download this release

Release Info

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

Code changes from version 1.10.6.8.1 to 1.10.6.9

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.10.6.8.1
7
  Author: codection
8
  Author URI: https://codection.com
9
  License: GPL2
@@ -17,7 +17,7 @@ if ( ! defined( 'ABSPATH' ) ) exit;
17
  $url_plugin = WP_PLUGIN_URL . '/' . str_replace( basename( __FILE__ ), "", plugin_basename( __FILE__ ) );
18
  $wp_users_fields = array( "id", "user_nicename", "user_url", "display_name", "nickname", "first_name", "last_name", "description", "jabber", "aim", "yim", "user_registered", "password", "user_pass", "locale" );
19
  $wp_min_fields = array("Username", "Email");
20
- $acui_fields = array( "bp_group", "bp_group_role" );
21
  $acui_restricted_fields = array_merge( $wp_users_fields, $wp_min_fields, $acui_fields );
22
 
23
  include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
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.10.6.9
7
  Author: codection
8
  Author URI: https://codection.com
9
  License: GPL2
17
  $url_plugin = WP_PLUGIN_URL . '/' . str_replace( basename( __FILE__ ), "", plugin_basename( __FILE__ ) );
18
  $wp_users_fields = array( "id", "user_nicename", "user_url", "display_name", "nickname", "first_name", "last_name", "description", "jabber", "aim", "yim", "user_registered", "password", "user_pass", "locale" );
19
  $wp_min_fields = array("Username", "Email");
20
+ $acui_fields = array( "bp_group", "bp_group_role", "role" );
21
  $acui_restricted_fields = array_merge( $wp_users_fields, $wp_min_fields, $acui_fields );
22
 
23
  include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
importer.php CHANGED
@@ -40,7 +40,7 @@ function acui_import_users( $file, $form_data, $attach_id = 0, $is_cron = false
40
  $headers = array();
41
  $headers_filtered = array();
42
  $update_existing_users = $form_data["update_existing_users"];
43
- $role = $form_data["role"];
44
  $update_roles_existing_users = $form_data["update_roles_existing_users"];
45
  $empty_cell_action = $form_data["empty_cell_action"];
46
 
@@ -104,11 +104,11 @@ function acui_import_users( $file, $form_data, $attach_id = 0, $is_cron = false
104
  $positions[ $acui_restricted_field ] = false;
105
  }
106
 
107
- foreach($data as $element){
108
  $headers[] = $element;
109
 
110
- if( in_array( strtolower($element) , $acui_restricted_fields ) )
111
- $positions[ strtolower($element) ] = $i;
112
 
113
  if( !in_array( strtolower( $element ), $acui_restricted_fields ) && !in_array( $element, $buddypress_fields ) )
114
  $headers_filtered[] = $element;
@@ -140,6 +140,8 @@ function acui_import_users( $file, $form_data, $attach_id = 0, $is_cron = false
140
  $problematic_row = false;
141
  $password_position = $positions["password"];
142
  $password = "";
 
 
143
  $id_position = $positions["id"];
144
 
145
  if ( !empty( $id_position ) )
@@ -152,7 +154,15 @@ function acui_import_users( $file, $form_data, $attach_id = 0, $is_cron = false
152
  if( $password_position === false )
153
  $password = wp_generate_password();
154
  else
155
- $password = $data[ $password_position ];
 
 
 
 
 
 
 
 
156
 
157
  if( !empty( $id ) ){ // if user have used id
158
  if( acui_user_id_exists( $id ) ){
@@ -614,7 +624,7 @@ function acui_options()
614
  </tr>
615
 
616
  <tr class="form-field">
617
- <th scope="row"><label for="role"><?php _e( 'Role', 'import-users-from-csv-with-meta' ); ?></label></th>
618
  <td>
619
  <?php
620
  $list_roles = acui_get_editable_roles();
@@ -627,7 +637,7 @@ function acui_options()
627
  }
628
  ?>
629
 
630
- <p class="description"><?php _e( 'If you choose more than one role, the roles would be assigned correctly but you should use some plugin like <a href="https://wordpress.org/plugins/user-role-editor/">User Role Editor</a> to manage them.', 'import-users-from-csv-with-meta' ); ?></p>
631
  </td>
632
  </tr>
633
 
@@ -702,7 +712,7 @@ function acui_options()
702
  <?php if( is_plugin_active( 'wp-members/wp-members.php' ) ): ?>
703
 
704
  <tr class="form-field form-required">
705
- <th scope="row"><label>Y</label></th>
706
  <td>
707
  <select name="activate_users_wp_members">
708
  <option value="no_activate"><?php _e( 'Do not activate users', 'import-users-from-csv-with-meta' ); ?></option>
@@ -931,6 +941,16 @@ function acui_options()
931
  </ul>
932
  </td>
933
  </tr>
 
 
 
 
 
 
 
 
 
 
934
  <tr valign="top">
935
  <th scope="row"><?php _e( "Serialized data", 'import-users-from-csv-with-meta' ); ?></th>
936
  <td><?php _e( "Plugin can now import serialized data. You have to use the serialized string directly in the CSV cell in order the plugin will be able to understand it as an serialized data instead as any other string.", 'import-users-from-csv-with-meta' ); ?>
@@ -959,6 +979,7 @@ function acui_options()
959
  </ol>
960
  </td>
961
  </tr>
 
962
  <?php if( is_plugin_active( 'woocommerce/woocommerce.php' ) ): ?>
963
 
964
  <tr valign="top">
@@ -988,7 +1009,6 @@ function acui_options()
988
  </ol>
989
  </td>
990
  </tr>
991
-
992
  <?php endif; ?>
993
 
994
  <?php if( is_plugin_active( 'buddypress/bp-loader.php' ) ): ?>
40
  $headers = array();
41
  $headers_filtered = array();
42
  $update_existing_users = $form_data["update_existing_users"];
43
+ $role_default = $form_data["role"];
44
  $update_roles_existing_users = $form_data["update_roles_existing_users"];
45
  $empty_cell_action = $form_data["empty_cell_action"];
46
 
104
  $positions[ $acui_restricted_field ] = false;
105
  }
106
 
107
+ foreach( $data as $element ){
108
  $headers[] = $element;
109
 
110
+ if( in_array( strtolower( $element ) , $acui_restricted_fields ) )
111
+ $positions[ strtolower( $element ) ] = $i;
112
 
113
  if( !in_array( strtolower( $element ), $acui_restricted_fields ) && !in_array( $element, $buddypress_fields ) )
114
  $headers_filtered[] = $element;
140
  $problematic_row = false;
141
  $password_position = $positions["password"];
142
  $password = "";
143
+ $role_position = $positions["role"];
144
+ $role = "";
145
  $id_position = $positions["id"];
146
 
147
  if ( !empty( $id_position ) )
154
  if( $password_position === false )
155
  $password = wp_generate_password();
156
  else
157
+ $password = $data[ $password_position ];
158
+
159
+ if( $role_position === false )
160
+ $role = $role_default;
161
+ else{
162
+ $roles_cells = explode( ',', $data[ $role_position ] );
163
+ array_walk( $roles_cells, 'trim' );
164
+ $role = $roles_cells;
165
+ }
166
 
167
  if( !empty( $id ) ){ // if user have used id
168
  if( acui_user_id_exists( $id ) ){
624
  </tr>
625
 
626
  <tr class="form-field">
627
+ <th scope="row"><label for="role"><?php _e( 'Default role', 'import-users-from-csv-with-meta' ); ?></label></th>
628
  <td>
629
  <?php
630
  $list_roles = acui_get_editable_roles();
637
  }
638
  ?>
639
 
640
+ <p class="description"><?php _e( 'You can also import roles from a CSV column. Please read documentation tab to see how it can be done. If you choose more than one role, the roles would be assigned correctly but you should use some plugin like <a href="https://wordpress.org/plugins/user-role-editor/">User Role Editor</a> to manage them.', 'import-users-from-csv-with-meta' ); ?></p>
641
  </td>
642
  </tr>
643
 
712
  <?php if( is_plugin_active( 'wp-members/wp-members.php' ) ): ?>
713
 
714
  <tr class="form-field form-required">
715
+ <th scope="row"><label>Activate user when they are being imported?</label></th>
716
  <td>
717
  <select name="activate_users_wp_members">
718
  <option value="no_activate"><?php _e( 'Do not activate users', 'import-users-from-csv-with-meta' ); ?></option>
941
  </ul>
942
  </td>
943
  </tr>
944
+ <tr valign="top">
945
+ <th scope="row"><?php _e( "Roles", 'import-users-from-csv-with-meta' ); ?></th>
946
+ <td><?php _e( "Plugin can import roles from the CSV. This is how it works:", 'import-users-from-csv-with-meta' ); ?>
947
+ <ul style="list-style:disc outside none; margin-left:2em;">
948
+ <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>
949
+ <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>
950
+ <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>
951
+ </ul>
952
+ </td>
953
+ </tr>
954
  <tr valign="top">
955
  <th scope="row"><?php _e( "Serialized data", 'import-users-from-csv-with-meta' ); ?></th>
956
  <td><?php _e( "Plugin can now import serialized data. You have to use the serialized string directly in the CSV cell in order the plugin will be able to understand it as an serialized data instead as any other string.", 'import-users-from-csv-with-meta' ); ?>
979
  </ol>
980
  </td>
981
  </tr>
982
+
983
  <?php if( is_plugin_active( 'woocommerce/woocommerce.php' ) ): ?>
984
 
985
  <tr valign="top">
1009
  </ol>
1010
  </td>
1011
  </tr>
 
1012
  <?php endif; ?>
1013
 
1014
  <?php if( is_plugin_active( 'buddypress/bp-loader.php' ) ): ?>
readme.txt CHANGED
@@ -4,7 +4,7 @@ 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.8
7
- Stable tag: 1.10.6.8.1
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -70,6 +70,9 @@ Plugin will automatically detect:
70
 
71
  == Changelog ==
72
 
 
 
 
73
  = 1.10.6.8.1 =
74
  * Thanks to @fiddla for debugging all this, as update_option with a value equals to true is saved as 1 in the database, we couldn't use the ==! or === operator to see if the option was active or not. Sorry for so many updates those days with this problems and thanks for the debugging
75
 
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.8
7
+ Stable tag: 1.10.6.9
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
70
 
71
  == Changelog ==
72
 
73
+ = 1.10.6.9 =
74
+ * Thanks to Peri Lane from Apis Productions you can now import roles from CSV. Read documentation to see the way to work.
75
+
76
  = 1.10.6.8.1 =
77
  * Thanks to @fiddla for debugging all this, as update_option with a value equals to true is saved as 1 in the database, we couldn't use the ==! or === operator to see if the option was active or not. Sorry for so many updates those days with this problems and thanks for the debugging
78