Import users from CSV with meta - Version 1.14.2.11

Version Description

  • Problem using "Yes, add new roles and not override existing one" was fixed
Download this release

Release Info

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

Code changes from version 1.14.2.10 to 1.14.2.11

addons/customer-area.php ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) exit;
4
+
5
+ if( is_plugin_active( 'customer-area/customer-area.php' ) && is_plugin_active( 'customer-area-managed-groups/customer-area-managed-groups.php' ) ){
6
+ add_filter( 'acui_restricted_fields', 'acui_cumg_restricted_fields', 10, 1 );
7
+ add_action( 'acui_documentation_after_plugins_activated', 'acui_cumg_documentation_after_plugins_activated' );
8
+ add_action( 'post_acui_import_single_user', 'acui_cumg_post_import_single_user', 10, 3 );
9
+ }
10
+
11
+ function acui_cumg_restricted_fields( $acui_restricted_fields ){
12
+ return array_merge( $acui_restricted_fields, array( 'customer_area_groups' ) );
13
+ }
14
+
15
+ function acui_cumg_documentation_after_plugins_activated(){
16
+ ?>
17
+ <tr valign="top">
18
+ <th scope="row"><?php _e( "WP Customer Area Managed Groups is activated", 'import-users-from-csv-with-meta' ); ?></th>
19
+ <td>
20
+ <?php _e( "You can import user groups and assign them to the users using the next format", 'import-users-from-csv-with-meta' ); ?>.
21
+ <ul style="list-style:disc outside none; margin-left:2em;">
22
+ <li><?php _e( "customer_area_groups as the column title", 'import-users-from-csv-with-meta' ); ?></li>
23
+ <li><?php _e( "The value of each cell will be the slug of the group", 'import-users-from-csv-with-meta' ); ?></li>
24
+ <li><?php _e( "If you want to import multiple values, you can use a list using commas to separate items", 'import-users-from-csv-with-meta' ); ?></li>
25
+ </ul>
26
+ </td>
27
+ </tr>
28
+ <?php
29
+ }
30
+
31
+ function acui_cumg_post_import_single_user( $headers, $row, $user_id ){
32
+ $pos = array_search( 'customer_area_groups', $headers );
33
+
34
+ if( $pos === FALSE )
35
+ return;
36
+
37
+ $user_groups = explode( ',', $row[ $pos ] );
38
+ $user_groups = array_filter( $user_groups, function( $value ){ return $value !== ''; } );
39
+ $new_group_ids = array();
40
+
41
+ foreach ( $user_groups as $user_group ) {
42
+ $group = get_page_by_path( $user_group, OBJECT, 'cuar_user_group' );
43
+ $new_group_ids[] = $group->ID;
44
+ }
45
+
46
+ $object_addon = new CUAR_UserGroupAddOn();
47
+ $user_groups = $object_addon->get_groups_of_user( $user_id );
48
+
49
+ // Remove from current groups that are not selected anymore
50
+ foreach ( $user_groups as $group ) {
51
+ if ( !in_array( $group->ID, $new_group_ids ) ) {
52
+ $object_addon->remove_user_from_group( $user_id, $group->ID );
53
+ }
54
+ }
55
+
56
+ // Add to all groups
57
+ foreach ( $new_group_ids as $new_group_id ) {
58
+ $object_addon->add_user_to_group( $user_id, $new_group_id );
59
+ }
60
+ }
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.14.2.10
7
  Author: codection
8
  Author URI: https://codection.com
9
  License: GPL2
@@ -11,7 +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' ) ) exit;
15
 
16
  $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" );
17
  $wp_min_fields = array("Username", "Email");
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.14.2.11
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
+ if ( ! defined( 'ABSPATH' ) ) exit;
15
 
16
  $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" );
17
  $wp_min_fields = array("Username", "Email");
importer.php CHANGED
@@ -323,7 +323,9 @@ function acui_import_users( $file, $form_data, $attach_id = 0, $is_cron = false,
323
  foreach ( $default_roles as $default_role ) {
324
  $user_object->remove_role( $default_role );
325
  }
 
326
 
 
327
  if( !empty( $role ) ){
328
  if( is_array( $role ) ){
329
  foreach ($role as $single_role) {
323
  foreach ( $default_roles as $default_role ) {
324
  $user_object->remove_role( $default_role );
325
  }
326
+ }
327
 
328
+ if( $update_roles_existing_users == 'yes' || $update_roles_existing_users == 'yes_no_override' || $created ){
329
  if( !empty( $role ) ){
330
  if( is_array( $role ) ){
331
  foreach ($role as $single_role) {
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.2.1
7
- Stable tag: 1.14.2.10
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -91,6 +91,9 @@ Plugin will automatically detect:
91
 
92
  == Changelog ==
93
 
 
 
 
94
  = 1.14.2.10 =
95
  * Change period was not working if you did not deactivate first the cron job, now it is solved and you can do it without deactivating cron job
96
 
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.2.1
7
+ Stable tag: 1.14.2.11
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
91
 
92
  == Changelog ==
93
 
94
+ = 1.14.2.11 =
95
+ * Problem using "Yes, add new roles and not override existing one" was fixed
96
+
97
  = 1.14.2.10 =
98
  * Change period was not working if you did not deactivate first the cron job, now it is solved and you can do it without deactivating cron job
99