Import users from CSV with meta - Version 1.14.1

Version Description

  • Compatibility with Groups plugin (https://es.wordpress.org/plugins/groups/)
Download this release

Release Info

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

Code changes from version 1.14.0.9 to 1.14.1

addons/groups.php ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) exit;
4
+
5
+ if( is_plugin_active( 'groups/groups.php' ) ){
6
+ add_filter( 'acui_restricted_fields', 'acui_g_restricted_fields', 10, 1 );
7
+ add_action( 'acui_documentation_after_plugins_activated', 'acui_g_documentation_after_plugins_activated' );
8
+ add_action( 'post_acui_import_single_user', 'acui_g_post_import_single_user', 10, 3 );
9
+ }
10
+
11
+ function acui_g_restricted_fields( $acui_restricted_fields ){
12
+ return array_merge( $acui_restricted_fields, array( 'group_id' ) );
13
+ }
14
+
15
+ function acui_g_documentation_after_plugins_activated(){
16
+ ?>
17
+ <tr valign="top">
18
+ <th scope="row"><?php _e( "Groups is activated", 'import-users-from-csv-with-meta' ); ?></th>
19
+ <td>
20
+ <?php _e( "You can import user and assign them to the users groups 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( "group_id as the column title", 'import-users-from-csv-with-meta' ); ?></li>
23
+ <li><?php _e( "The value of each cell will be the ID of the group that you want to assign to this user", '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_g_post_import_single_user( $headers, $row, $user_id ){
32
+ $pos = array_search( 'group_id', $headers );
33
+
34
+ if( $pos === FALSE )
35
+ return;
36
+
37
+ // groups that appears in the CSV
38
+ $user_groups_csv = explode( ',', $row[ $pos ] );
39
+ $user_groups_csv = array_filter( $user_groups_csv, function( $value ){ return $value !== ''; } );
40
+
41
+ // groups that user belongs to
42
+ $groups_user = new Groups_User( $user_id );
43
+ $user_group_ids = $groups_user->group_ids;
44
+
45
+ // first we look into all current user groups, if they do not appear in CSV it will be removed
46
+ foreach ( $user_group_ids as $user_group_id ) {
47
+ if( !in_array( $user_group_id, $user_groups_csv ) )
48
+ Groups_User_Group::delete( $user_id, $user_group_id );
49
+ }
50
+
51
+ // finally we loop into groups that are present in CSV data, if they already exists, we do nothing, if not, we add it
52
+ foreach ( $user_groups_csv as $user_group_csv ) {
53
+ if( !in_array( $user_group_csv, $user_group_ids ) )
54
+ Groups_User_Group::create( array( 'user_id' => $user_id, 'group_id' => $user_group_csv ) );
55
+ }
56
+ }
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.0.9
7
  Author: codection
8
  Author URI: https://codection.com
9
  License: GPL2
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.1
7
  Author: codection
8
  Author URI: https://codection.com
9
  License: GPL2
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: carazo, hornero
3
  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
7
- Stable tag: 1.14.0.9
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -36,6 +36,7 @@ Moreover this plugin is compatible with:
36
  * Paid Membership Pro: to import memberships
37
  * Indeed Ultimate Membership Pro: to import memberships
38
  * Allow Multiple Accounts: plugin will allow the same rules importing than this plugin
 
39
  * New User Approve: you can import users and approbe/wait for approve them
40
  * Users Group: to assign users to groups while importing
41
  * WP LMS Course: to enroll users in the courses while importing
@@ -90,6 +91,9 @@ Plugin will automatically detect:
90
 
91
  == Changelog ==
92
 
 
 
 
93
  = 1.14.0.9 =
94
  * WP-CLI does not manage our previous version
95
  * New tab "New features" added
3
  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.1
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
36
  * Paid Membership Pro: to import memberships
37
  * Indeed Ultimate Membership Pro: to import memberships
38
  * Allow Multiple Accounts: plugin will allow the same rules importing than this plugin
39
+ * Groups: to assign users to groups while importing
40
  * New User Approve: you can import users and approbe/wait for approve them
41
  * Users Group: to assign users to groups while importing
42
  * WP LMS Course: to enroll users in the courses while importing
91
 
92
  == Changelog ==
93
 
94
+ = 1.14.1 =
95
+ * Compatibility with Groups plugin (https://es.wordpress.org/plugins/groups/)
96
+
97
  = 1.14.0.9 =
98
  * WP-CLI does not manage our previous version
99
  * New tab "New features" added