Version Description
- BuddyPress/BuddyBoss avatar can now be imported
- Code improvements
Download this release
Release Info
Developer | carazo |
Plugin | Import users from CSV with meta |
Version | 1.16.3.1 |
Comparing to | |
See all releases |
Code changes from version 1.16.3 to 1.16.3.1
- addons/buddypress.php +63 -3
- addons/customer-area.php +57 -53
- import-users-from-csv-with-meta.php +1 -1
- readme.txt +7 -3
addons/buddypress.php
CHANGED
@@ -8,10 +8,16 @@ if( !is_plugin_active( 'buddypress/bp-loader.php' ) && !function_exists( 'bp_is_
|
|
8 |
|
9 |
class ACUI_Buddypress{
|
10 |
function __construct(){
|
|
|
11 |
add_action( 'acui_tab_import_before_import_button', array( $this, 'show_compatibility' ) );
|
12 |
add_action( 'acui_documentation_after_plugins_activated', array( $this, 'documentation' ) );
|
13 |
add_filter( 'acui_export_columns', array( $this, 'export_columns' ), 10, 1 );
|
14 |
add_filter( 'acui_export_data', array( $this, 'export_data' ), 10, 3 );
|
|
|
|
|
|
|
|
|
|
|
15 |
}
|
16 |
|
17 |
function show_compatibility(){
|
@@ -34,12 +40,12 @@ class ACUI_Buddypress{
|
|
34 |
}
|
35 |
}
|
36 |
?>
|
37 |
-
<h2><?php _e( 'BuddyPress compatibility', 'import-users-from-csv-with-meta'); ?></h2>
|
38 |
|
39 |
<table class="form-table">
|
40 |
<tbody>
|
41 |
<tr class="form-field form-required">
|
42 |
-
<th scope="row"><label><?php _e( 'BuddyPress users', 'import-users-from-csv-with-meta' ); ?></label></th>
|
43 |
<td><?php _e( 'You can insert any profile from BuddyPress using his name as header. Plugin will check, before import, which fields are defined in BuddyPress and will assign it in the update. You can use this fields:', 'import-users-from-csv-with-meta' ); ?>
|
44 |
<ul style="list-style:disc outside none;margin-left:2em;">
|
45 |
<?php foreach ( $buddypress_fields as $buddypress_field ): ?><li><?php echo $buddypress_field; ?></li><?php endforeach; ?>
|
@@ -57,7 +63,16 @@ class ACUI_Buddypress{
|
|
57 |
function documentation(){
|
58 |
?>
|
59 |
<tr valign="top">
|
60 |
-
<th scope="row"><?php _e(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
61 |
<td><?php _e( "You can use the <strong>profile fields</strong> you have created and also you can set one or more groups for each user. For example:", 'import-users-from-csv-with-meta' ); ?>
|
62 |
<ul style="list-style:disc outside none; margin-left:2em;">
|
63 |
<li><?php _e( "If you want to assign an user to a group you have to create a column 'bp_group' and a column 'bp_group_role'", 'import-users-from-csv-with-meta' ); ?></li>
|
@@ -127,5 +142,50 @@ class ACUI_Buddypress{
|
|
127 |
|
128 |
return $row;
|
129 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
130 |
}
|
131 |
new ACUI_Buddypress();
|
8 |
|
9 |
class ACUI_Buddypress{
|
10 |
function __construct(){
|
11 |
+
add_filter( 'acui_restricted_fields', array( $this, 'restricted_fields' ), 10, 1 );
|
12 |
add_action( 'acui_tab_import_before_import_button', array( $this, 'show_compatibility' ) );
|
13 |
add_action( 'acui_documentation_after_plugins_activated', array( $this, 'documentation' ) );
|
14 |
add_filter( 'acui_export_columns', array( $this, 'export_columns' ), 10, 1 );
|
15 |
add_filter( 'acui_export_data', array( $this, 'export_data' ), 10, 3 );
|
16 |
+
add_action( 'post_acui_import_single_user', array( $this, 'import_avatar' ), 10, 3 );
|
17 |
+
}
|
18 |
+
|
19 |
+
function restricted_fields( $acui_restricted_fields ){
|
20 |
+
return array_merge( $acui_restricted_fields, array( 'bp_avatar' ) );
|
21 |
}
|
22 |
|
23 |
function show_compatibility(){
|
40 |
}
|
41 |
}
|
42 |
?>
|
43 |
+
<h2><?php _e( 'BuddyPress & BuddyBoss compatibility', 'import-users-from-csv-with-meta'); ?></h2>
|
44 |
|
45 |
<table class="form-table">
|
46 |
<tbody>
|
47 |
<tr class="form-field form-required">
|
48 |
+
<th scope="row"><label><?php _e( 'BuddyPress/BuddyBoss users', 'import-users-from-csv-with-meta' ); ?></label></th>
|
49 |
<td><?php _e( 'You can insert any profile from BuddyPress using his name as header. Plugin will check, before import, which fields are defined in BuddyPress and will assign it in the update. You can use this fields:', 'import-users-from-csv-with-meta' ); ?>
|
50 |
<ul style="list-style:disc outside none;margin-left:2em;">
|
51 |
<?php foreach ( $buddypress_fields as $buddypress_field ): ?><li><?php echo $buddypress_field; ?></li><?php endforeach; ?>
|
63 |
function documentation(){
|
64 |
?>
|
65 |
<tr valign="top">
|
66 |
+
<th scope="row"><?php _e( 'BuddyPress/BuddyBoss avatar', 'import-users-from-csv-with-meta' ); ?></th>
|
67 |
+
<td><?php _e( 'You can import users avatars using a column called <strong>bp_avatar</strong>, in this field you can place:', 'import-users-from-csv-with-meta' ); ?>
|
68 |
+
<ul style="list-style:disc outside none;margin-left:2em;">
|
69 |
+
<li>An integer which identify the ID of an attachment uploaded to your media library</li>
|
70 |
+
<li>A string that contain a path or an URL to the image</li>
|
71 |
+
</ul>
|
72 |
+
</td>
|
73 |
+
</tr>
|
74 |
+
<tr valign="top">
|
75 |
+
<th scope="row"><?php _e( "BuddyPress or BuddyBoss is activated", 'import-users-from-csv-with-meta' ); ?></th>
|
76 |
<td><?php _e( "You can use the <strong>profile fields</strong> you have created and also you can set one or more groups for each user. For example:", 'import-users-from-csv-with-meta' ); ?>
|
77 |
<ul style="list-style:disc outside none; margin-left:2em;">
|
78 |
<li><?php _e( "If you want to assign an user to a group you have to create a column 'bp_group' and a column 'bp_group_role'", 'import-users-from-csv-with-meta' ); ?></li>
|
142 |
|
143 |
return $row;
|
144 |
}
|
145 |
+
|
146 |
+
function import_avatar( $headers, $row, $user_id ){
|
147 |
+
$pos = array_search( 'bp_avatar', $headers );
|
148 |
+
|
149 |
+
if( $pos === FALSE )
|
150 |
+
return;
|
151 |
+
|
152 |
+
$this->import_avatar_raw( $user_id, $row[ $pos ] );
|
153 |
+
}
|
154 |
+
|
155 |
+
function import_avatar_raw( $user_id, $source ){
|
156 |
+
$avatar_dir = bp_core_avatar_upload_path() . '/avatars';
|
157 |
+
|
158 |
+
if ( ! file_exists( $avatar_dir ) ) {
|
159 |
+
if ( ! wp_mkdir_p( $avatar_dir ) ) {
|
160 |
+
return false;
|
161 |
+
}
|
162 |
+
}
|
163 |
+
|
164 |
+
$avatar_folder_dir = apply_filters( 'bp_core_avatar_folder_dir', $avatar_dir . '/' . $user_id, $user_id, 'user', 'avatars' );
|
165 |
+
|
166 |
+
if ( ! is_dir( $avatar_folder_dir ) ) {
|
167 |
+
if ( ! wp_mkdir_p( $avatar_folder_dir ) ) {
|
168 |
+
return false;
|
169 |
+
}
|
170 |
+
}
|
171 |
+
|
172 |
+
$original_file = $avatar_folder_dir . '/import-export-users-customers-bp-avatar-' . $user_id . '.png';
|
173 |
+
$data = ( (string)(int)$source == $source ) ? file_get_contents( get_attached_file( $source ) ) : file_get_contents( $source );
|
174 |
+
|
175 |
+
if ( file_put_contents( $original_file, $data ) ) {
|
176 |
+
$avatar_to_crop = str_replace( bp_core_avatar_upload_path(), '', $original_file );
|
177 |
+
|
178 |
+
$crop_args = array(
|
179 |
+
'item_id' => $user_id,
|
180 |
+
'original_file' => $avatar_to_crop,
|
181 |
+
'crop_x' => 0,
|
182 |
+
'crop_y' => 0,
|
183 |
+
);
|
184 |
+
|
185 |
+
return bp_core_avatar_handle_crop( $crop_args );
|
186 |
+
} else {
|
187 |
+
return false;
|
188 |
+
}
|
189 |
+
}
|
190 |
}
|
191 |
new ACUI_Buddypress();
|
addons/customer-area.php
CHANGED
@@ -6,63 +6,67 @@ if( !is_plugin_active( 'customer-area/customer-area.php' ) || !is_plugin_active(
|
|
6 |
return;
|
7 |
}
|
8 |
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
}
|
16 |
-
|
17 |
-
function acui_cumg_documentation_after_plugins_activated(){
|
18 |
-
?>
|
19 |
-
<tr valign="top">
|
20 |
-
<th scope="row"><?php _e( "WP Customer Area Managed Groups is activated", 'import-users-from-csv-with-meta' ); ?></th>
|
21 |
-
<td>
|
22 |
-
<?php _e( "You can import user groups and assign them to the users using the next format", 'import-users-from-csv-with-meta' ); ?>.
|
23 |
-
<ul style="list-style:disc outside none; margin-left:2em;">
|
24 |
-
<li><?php _e( "customer_area_groups as the column title", 'import-users-from-csv-with-meta' ); ?></li>
|
25 |
-
<li><?php _e( "The value of each cell will be the slug of the group", 'import-users-from-csv-with-meta' ); ?></li>
|
26 |
-
<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>
|
27 |
-
</ul>
|
28 |
-
</td>
|
29 |
-
</tr>
|
30 |
-
<?php
|
31 |
-
}
|
32 |
-
|
33 |
-
function acui_cumg_post_import_single_user( $headers, $row, $user_id ){
|
34 |
-
$pos = array_search( 'customer_area_groups', $headers );
|
35 |
-
|
36 |
-
if( $pos === FALSE )
|
37 |
-
return;
|
38 |
-
|
39 |
-
$user_groups = explode( ',', $row[ $pos ] );
|
40 |
-
$user_groups = array_filter( $user_groups, function( $value ){ return $value !== ''; } );
|
41 |
-
$new_group_ids = array();
|
42 |
-
|
43 |
-
foreach ( $user_groups as $user_group ) {
|
44 |
-
$group = get_page_by_path( $user_group, OBJECT, 'cuar_user_group' );
|
45 |
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
50 |
return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
51 |
}
|
52 |
-
}
|
53 |
-
|
54 |
-
$object_addon = new CUAR_UserGroupAddOn();
|
55 |
-
$user_groups = $object_addon->get_groups_of_user( $user_id );
|
56 |
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
$object_addon->remove_user_from_group( $user_id, $group->ID );
|
61 |
}
|
62 |
}
|
63 |
-
|
64 |
-
// Add to all groups
|
65 |
-
foreach ( $new_group_ids as $new_group_id ) {
|
66 |
-
$object_addon->add_user_to_group( $user_id, $new_group_id );
|
67 |
-
}
|
68 |
}
|
6 |
return;
|
7 |
}
|
8 |
|
9 |
+
class ACUI_CustomerArea{
|
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, 'after_plugins_activated' ) );
|
13 |
+
add_action( 'post_acui_import_single_user', array( $this, 'post_import_single_user' ), 10, 3 );
|
14 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
|
16 |
+
function restricted_fields( $acui_restricted_fields ){
|
17 |
+
return array_merge( $acui_restricted_fields, array( 'customer_area_groups' ) );
|
18 |
+
}
|
19 |
+
|
20 |
+
function after_plugins_activated(){
|
21 |
+
?>
|
22 |
+
<tr valign="top">
|
23 |
+
<th scope="row"><?php _e( "WP Customer Area Managed Groups is activated", 'import-users-from-csv-with-meta' ); ?></th>
|
24 |
+
<td>
|
25 |
+
<?php _e( "You can import user groups and assign them to the users using the next format", 'import-users-from-csv-with-meta' ); ?>.
|
26 |
+
<ul style="list-style:disc outside none; margin-left:2em;">
|
27 |
+
<li><?php _e( "customer_area_groups as the column title", 'import-users-from-csv-with-meta' ); ?></li>
|
28 |
+
<li><?php _e( "The value of each cell will be the slug of the group", 'import-users-from-csv-with-meta' ); ?></li>
|
29 |
+
<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>
|
30 |
+
</ul>
|
31 |
+
</td>
|
32 |
+
</tr>
|
33 |
+
<?php
|
34 |
+
}
|
35 |
+
|
36 |
+
function post_import_single_user( $headers, $row, $user_id ){
|
37 |
+
$pos = array_search( 'customer_area_groups', $headers );
|
38 |
+
|
39 |
+
if( $pos === FALSE )
|
40 |
return;
|
41 |
+
|
42 |
+
$user_groups = explode( ',', $row[ $pos ] );
|
43 |
+
$user_groups = array_filter( $user_groups, function( $value ){ return $value !== ''; } );
|
44 |
+
$new_group_ids = array();
|
45 |
+
|
46 |
+
foreach ( $user_groups as $user_group ) {
|
47 |
+
$group = get_page_by_path( $user_group, OBJECT, 'cuar_user_group' );
|
48 |
+
|
49 |
+
if( is_object( $group ) )
|
50 |
+
$new_group_ids[] = $group->ID;
|
51 |
+
else{
|
52 |
+
echo "$group is not a name of a group in Customer Area<br/>";
|
53 |
+
return;
|
54 |
+
}
|
55 |
+
}
|
56 |
+
|
57 |
+
$object_addon = new CUAR_UserGroupAddOn();
|
58 |
+
$user_groups = $object_addon->get_groups_of_user( $user_id );
|
59 |
+
|
60 |
+
// Remove from current groups that are not selected anymore
|
61 |
+
foreach ( $user_groups as $group ) {
|
62 |
+
if ( !in_array( $group->ID, $new_group_ids ) ) {
|
63 |
+
$object_addon->remove_user_from_group( $user_id, $group->ID );
|
64 |
+
}
|
65 |
}
|
|
|
|
|
|
|
|
|
66 |
|
67 |
+
// Add to all groups
|
68 |
+
foreach ( $new_group_ids as $new_group_id ) {
|
69 |
+
$object_addon->add_user_to_group( $user_id, $new_group_id );
|
|
|
70 |
}
|
71 |
}
|
|
|
|
|
|
|
|
|
|
|
72 |
}
|
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.16.3
|
7 |
Author: codection
|
8 |
Author URI: https://codection.com
|
9 |
License: GPL2
|
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.16.3.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.5.
|
7 |
-
Stable tag: 1.16.3
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -31,7 +31,7 @@ Moreover this plugin is compatible with many other plugins to be able to import
|
|
31 |
* WooCommerce: to import the customer data
|
32 |
* WooCommerce Memberships: to import memberships
|
33 |
* WooCommerce Subscriptions: to create subscriptions associated with users while they are being imported
|
34 |
-
* BuddyPress: to import custom BuddyPress fields, groups and roles
|
35 |
* Advanced Custom Fields: to import data to the fields you define there
|
36 |
* Paid Membership Pro: to import memberships
|
37 |
* Indeed Ultimate Membership Pro: to import memberships
|
@@ -103,6 +103,10 @@ Plugin will automatically detect:
|
|
103 |
|
104 |
== Changelog ==
|
105 |
|
|
|
|
|
|
|
|
|
106 |
= 1.16.3 =
|
107 |
* Now you can use HTML emails
|
108 |
* Code improvements
|
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.5.3
|
7 |
+
Stable tag: 1.16.3.1
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
31 |
* WooCommerce: to import the customer data
|
32 |
* WooCommerce Memberships: to import memberships
|
33 |
* WooCommerce Subscriptions: to create subscriptions associated with users while they are being imported
|
34 |
+
* BuddyPress: to import custom BuddyPress avatars, fields, groups and roles
|
35 |
* Advanced Custom Fields: to import data to the fields you define there
|
36 |
* Paid Membership Pro: to import memberships
|
37 |
* Indeed Ultimate Membership Pro: to import memberships
|
103 |
|
104 |
== Changelog ==
|
105 |
|
106 |
+
= 1.16.3.1 =
|
107 |
+
* BuddyPress/BuddyBoss avatar can now be imported
|
108 |
+
* Code improvements
|
109 |
+
|
110 |
= 1.16.3 =
|
111 |
* Now you can use HTML emails
|
112 |
* Code improvements
|