Version Description
- You can now export data from BuddyPress groups
- BuddyPress addon is now a class instead of different methods
Download this release
Release Info
Developer | carazo |
Plugin | Import users from CSV with meta |
Version | 1.15.9.1 |
Comparing to | |
See all releases |
Code changes from version 1.15.9 to 1.15.9.1
- addons/buddypress.php +108 -51
- classes/export.php +13 -37
- import-users-from-csv-with-meta.php +1 -1
- readme.txt +6 -2
addons/buddypress.php
CHANGED
@@ -6,63 +6,120 @@ if( !is_plugin_active( 'buddypress/bp-loader.php' ) ){
|
|
6 |
return;
|
7 |
}
|
8 |
|
9 |
-
|
10 |
-
|
|
|
|
|
|
|
|
|
|
|
11 |
|
12 |
-
function
|
13 |
-
|
14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
}
|
16 |
|
17 |
-
|
18 |
-
|
19 |
-
|
|
|
|
|
|
|
|
|
|
|
20 |
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
|
|
|
|
|
|
27 |
}
|
28 |
}
|
29 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
}
|
31 |
-
?>
|
32 |
-
<h2><?php _e( 'BuddyPress compatibility', 'import-users-from-csv-with-meta'); ?></h2>
|
33 |
-
|
34 |
-
<table class="form-table">
|
35 |
-
<tbody>
|
36 |
-
<tr class="form-field form-required">
|
37 |
-
<th scope="row"><label><?php _e( 'BuddyPress users', 'import-users-from-csv-with-meta' ); ?></label></th>
|
38 |
-
<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' ); ?>
|
39 |
-
<ul style="list-style:disc outside none;margin-left:2em;">
|
40 |
-
<?php foreach ( $buddypress_fields as $buddypress_field ): ?><li><?php echo $buddypress_field; ?></li><?php endforeach; ?>
|
41 |
-
</ul>
|
42 |
-
<?php _e( 'Remember that all date fields have to be imported using a format like this: 2016-01-01 00:00:00', 'import-users-from-csv-with-meta' ); ?>
|
43 |
-
|
44 |
-
<p class="description"><strong>(<?php _e( 'Only for', 'import-users-from-csv-with-meta' ); ?> <a href="https://wordpress.org/plugins/buddypress/">BuddyPress</a> <?php _e( 'users', 'import-users-from-csv-with-meta' ); ?></strong>.)</p>
|
45 |
-
</td>
|
46 |
-
</tr>
|
47 |
-
</tbody>
|
48 |
-
</table>
|
49 |
-
<?php
|
50 |
-
}
|
51 |
|
52 |
-
function
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
|
|
|
|
|
|
|
6 |
return;
|
7 |
}
|
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(){
|
18 |
+
if( !class_exists( "BP_XProfile_Group" ) ){
|
19 |
+
require_once( WP_PLUGIN_DIR . "/buddypress/bp-xprofile/classes/class-bp-xprofile-group.php" );
|
20 |
+
}
|
21 |
+
|
22 |
+
$buddypress_fields = array();
|
23 |
+
$buddypress_types = array();
|
24 |
+
$profile_groups = BP_XProfile_Group::get( array( 'fetch_fields' => true ) );
|
25 |
+
|
26 |
+
if ( !empty( $profile_groups ) ) {
|
27 |
+
foreach ( $profile_groups as $profile_group ) {
|
28 |
+
if ( !empty( $profile_group->fields ) ) {
|
29 |
+
foreach ( $profile_group->fields as $field ) {
|
30 |
+
$buddypress_fields[] = $field->name;
|
31 |
+
$buddypress_types[] = $field->type;
|
32 |
+
}
|
33 |
+
}
|
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; ?>
|
46 |
+
</ul>
|
47 |
+
<?php _e( 'Remember that all date fields have to be imported using a format like this: 2016-01-01 00:00:00', 'import-users-from-csv-with-meta' ); ?>
|
48 |
+
|
49 |
+
<p class="description"><strong>(<?php _e( 'Only for', 'import-users-from-csv-with-meta' ); ?> <a href="https://wordpress.org/plugins/buddypress/">BuddyPress</a> <?php _e( 'users', 'import-users-from-csv-with-meta' ); ?></strong>.)</p>
|
50 |
+
</td>
|
51 |
+
</tr>
|
52 |
+
</tbody>
|
53 |
+
</table>
|
54 |
+
<?php
|
55 |
+
}
|
56 |
+
|
57 |
+
function documentation(){
|
58 |
+
?>
|
59 |
+
<tr valign="top">
|
60 |
+
<th scope="row"><?php _e( "BuddyPress is activated", 'import-users-from-csv-with-meta' ); ?></th>
|
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>
|
64 |
+
<li><?php _e( "Then in each cell you have to fill with the BuddyPress <strong>group slug</strong>", 'import-users-from-csv-with-meta' ); ?></li>
|
65 |
+
<li><?php _e( "And the role assigned in this group: <em>Administrator, Moderator or Member</em>", 'import-users-from-csv-with-meta' ); ?></li>
|
66 |
+
<li><?php _e( "You can do it with multiple groups at the same time using commas to separate different groups, in bp_group column, i.e.: <em>group_1, group_2, group_3</em>", 'import-users-from-csv-with-meta' ); ?></li>
|
67 |
+
<li><?php _e( "But you will have to assign a role for each group: <em>Moderator,Moderator,Member,Member</em>", 'import-users-from-csv-with-meta' ); ?></li>
|
68 |
+
<li><?php _e( "If you get some error of this kind:", 'import-users-from-csv-with-meta' ); ?> <code>Fatal error: Class 'BP_XProfile_Group'</code> <?php _e( "please enable Buddypress Extended Profile then import the csv file. You can then disable this afterwards", 'import-users-from-csv-with-meta' ); ?></li>
|
69 |
+
</ul>
|
70 |
+
</td>
|
71 |
+
</tr>
|
72 |
+
<?php
|
73 |
}
|
74 |
|
75 |
+
function get_fields(){
|
76 |
+
if( !is_plugin_active( 'buddypress/bp-loader.php' ) ){
|
77 |
+
return array();
|
78 |
+
}
|
79 |
+
|
80 |
+
if( !class_exists( "BP_XProfile_Group" ) ){
|
81 |
+
require_once( WP_PLUGIN_DIR . "/buddypress/bp-xprofile/classes/class-bp-xprofile-group.php" );
|
82 |
+
}
|
83 |
|
84 |
+
$buddypress_fields = array();
|
85 |
+
$profile_groups = BP_XProfile_Group::get( array( 'fetch_fields' => true ) );
|
86 |
+
|
87 |
+
if ( !empty( $profile_groups ) ) {
|
88 |
+
foreach ( $profile_groups as $profile_group ) {
|
89 |
+
if ( !empty( $profile_group->fields ) ) {
|
90 |
+
foreach ( $profile_group->fields as $field ) {
|
91 |
+
$buddypress_fields[] = $field->name;
|
92 |
+
}
|
93 |
}
|
94 |
}
|
95 |
}
|
96 |
+
|
97 |
+
return $buddypress_fields;
|
98 |
+
}
|
99 |
+
|
100 |
+
function get_groups( $user_id ){
|
101 |
+
$groups = BP_Groups_Member::get_group_ids( $user_id );
|
102 |
+
return implode( ",", $groups['groups'] );
|
103 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
104 |
|
105 |
+
function export_columns( $row ){
|
106 |
+
foreach ( $this->get_fields() as $key ) {
|
107 |
+
$row[] = $key;
|
108 |
+
}
|
109 |
+
|
110 |
+
$row[] = 'bp_group';
|
111 |
+
|
112 |
+
return $row;
|
113 |
+
}
|
114 |
+
|
115 |
+
function export_data( $row, $user ){
|
116 |
+
foreach ( $this->get_fields() as $key ) {
|
117 |
+
$row[] = ACUI_Exporter::prepare( $key, xprofile_get_field_data( $key, $user, 'comma' ), $datetime_format );
|
118 |
+
}
|
119 |
+
|
120 |
+
$row[] = $this->get_groups( $user );
|
121 |
+
|
122 |
+
return $row;
|
123 |
+
}
|
124 |
+
}
|
125 |
+
new ACUI_Buddypress();
|
classes/export.php
CHANGED
@@ -15,6 +15,7 @@ class ACUI_Exporter{
|
|
15 |
|
16 |
add_action( 'wp_ajax_acui_export_users_csv', array( $this, 'export_users_csv' ) );
|
17 |
add_filter( 'acui_export_get_key_user_data', array( $this, 'filter_key_user_id' ) );
|
|
|
18 |
}
|
19 |
|
20 |
public static function admin_gui(){
|
@@ -89,13 +90,17 @@ class ACUI_Exporter{
|
|
89 |
<?php
|
90 |
}
|
91 |
|
92 |
-
function is_valid_timestamp( $timestamp ){
|
93 |
return ( (string) (int) $timestamp === $timestamp ) && ( $timestamp <= PHP_INT_MAX ) && ( $timestamp >= ~PHP_INT_MAX );
|
94 |
}
|
95 |
|
96 |
-
function
|
|
|
|
|
|
|
|
|
97 |
$timestamp_keys = apply_filters( 'acui_export_timestamp_keys', array( 'wc_last_active' ) );
|
98 |
-
$non_date_keys = apply_filters( 'acui_export_non_date_keys',
|
99 |
|
100 |
if( is_array( $value ) ){
|
101 |
return serialize( $value );
|
@@ -106,7 +111,7 @@ class ACUI_Exporter{
|
|
106 |
elseif( strtotime( $value ) ){ // dates in datetime format
|
107 |
return date( $datetime_format, strtotime( $value ) );
|
108 |
}
|
109 |
-
elseif( (
|
110 |
return date( $datetime_format, $value );
|
111 |
}
|
112 |
else{
|
@@ -164,9 +169,7 @@ class ACUI_Exporter{
|
|
164 |
$row[] = $key;
|
165 |
}
|
166 |
|
167 |
-
|
168 |
-
$row[] = $key;
|
169 |
-
}
|
170 |
|
171 |
$data[] = $row;
|
172 |
$row = array();
|
@@ -178,18 +181,16 @@ class ACUI_Exporter{
|
|
178 |
|
179 |
foreach ( $this->user_data as $key ) {
|
180 |
$key = apply_filters( 'acui_export_get_key_user_data', $key );
|
181 |
-
$row[] =
|
182 |
}
|
183 |
|
184 |
$row[] = $this->get_role( $user );
|
185 |
|
186 |
foreach ( $this->get_user_meta_keys() as $key ) {
|
187 |
-
$row[] =
|
188 |
}
|
189 |
|
190 |
-
|
191 |
-
$row[] = $this->prepare( $key, xprofile_get_field_data( $key, $user, 'comma' ), $datetime_format );
|
192 |
-
}
|
193 |
|
194 |
$data[] = $row;
|
195 |
$row = array();
|
@@ -240,31 +241,6 @@ class ACUI_Exporter{
|
|
240 |
return apply_filters( 'acui_export_get_user_meta_keys', $meta_keys );
|
241 |
}
|
242 |
|
243 |
-
function get_buddypress_fields(){
|
244 |
-
if( !is_plugin_active( 'buddypress/bp-loader.php' ) ){
|
245 |
-
return array();
|
246 |
-
}
|
247 |
-
|
248 |
-
if( !class_exists( "BP_XProfile_Group" ) ){
|
249 |
-
require_once( WP_PLUGIN_DIR . "/buddypress/bp-xprofile/classes/class-bp-xprofile-group.php" );
|
250 |
-
}
|
251 |
-
|
252 |
-
$buddypress_fields = array();
|
253 |
-
$profile_groups = BP_XProfile_Group::get( array( 'fetch_fields' => true ) );
|
254 |
-
|
255 |
-
if ( !empty( $profile_groups ) ) {
|
256 |
-
foreach ( $profile_groups as $profile_group ) {
|
257 |
-
if ( !empty( $profile_group->fields ) ) {
|
258 |
-
foreach ( $profile_group->fields as $field ) {
|
259 |
-
$buddypress_fields[] = $field->name;
|
260 |
-
}
|
261 |
-
}
|
262 |
-
}
|
263 |
-
}
|
264 |
-
|
265 |
-
return $buddypress_fields;
|
266 |
-
}
|
267 |
-
|
268 |
function get_user_id_list( $role, $from, $to ){
|
269 |
$args = array( 'fields' => array( 'ID' ) );
|
270 |
|
15 |
|
16 |
add_action( 'wp_ajax_acui_export_users_csv', array( $this, 'export_users_csv' ) );
|
17 |
add_filter( 'acui_export_get_key_user_data', array( $this, 'filter_key_user_id' ) );
|
18 |
+
add_filter( 'acui_export_non_date_keys', array( $this, 'get_non_date_keys' ), 1, 1 );
|
19 |
}
|
20 |
|
21 |
public static function admin_gui(){
|
90 |
<?php
|
91 |
}
|
92 |
|
93 |
+
static function is_valid_timestamp( $timestamp ){
|
94 |
return ( (string) (int) $timestamp === $timestamp ) && ( $timestamp <= PHP_INT_MAX ) && ( $timestamp >= ~PHP_INT_MAX );
|
95 |
}
|
96 |
|
97 |
+
function get_non_date_keys( $non_date_keys ){
|
98 |
+
return array_merge( $non_date_keys, $this->user_data, $this->woocommerce_default_user_meta_keys, $this->other_non_date_keys );
|
99 |
+
}
|
100 |
+
|
101 |
+
public static function prepare( $key, $value, $datetime_format ){
|
102 |
$timestamp_keys = apply_filters( 'acui_export_timestamp_keys', array( 'wc_last_active' ) );
|
103 |
+
$non_date_keys = apply_filters( 'acui_export_non_date_keys', array() );
|
104 |
|
105 |
if( is_array( $value ) ){
|
106 |
return serialize( $value );
|
111 |
elseif( strtotime( $value ) ){ // dates in datetime format
|
112 |
return date( $datetime_format, strtotime( $value ) );
|
113 |
}
|
114 |
+
elseif( ( self::is_valid_timestamp( $value ) && strlen( $value ) > 4 ) || in_array( $key, $timestamp_keys) ){ // dates in timestamp format
|
115 |
return date( $datetime_format, $value );
|
116 |
}
|
117 |
else{
|
169 |
$row[] = $key;
|
170 |
}
|
171 |
|
172 |
+
$row = apply_filters( 'acui_export_columns', $row );
|
|
|
|
|
173 |
|
174 |
$data[] = $row;
|
175 |
$row = array();
|
181 |
|
182 |
foreach ( $this->user_data as $key ) {
|
183 |
$key = apply_filters( 'acui_export_get_key_user_data', $key );
|
184 |
+
$row[] = self::prepare( $key, $userdata->data->{$key}, $datetime_format );
|
185 |
}
|
186 |
|
187 |
$row[] = $this->get_role( $user );
|
188 |
|
189 |
foreach ( $this->get_user_meta_keys() as $key ) {
|
190 |
+
$row[] = self::prepare( $key, get_user_meta( $user, $key, true ), $datetime_format );
|
191 |
}
|
192 |
|
193 |
+
$row = apply_filters( 'acui_export_data', $row, $user, $datetime_format );
|
|
|
|
|
194 |
|
195 |
$data[] = $row;
|
196 |
$row = array();
|
241 |
return apply_filters( 'acui_export_get_user_meta_keys', $meta_keys );
|
242 |
}
|
243 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
244 |
function get_user_id_list( $role, $from, $to ){
|
245 |
$args = array( 'fields' => array( 'ID' ) );
|
246 |
|
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.15.9
|
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.15.9.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.15.9
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -99,6 +99,10 @@ Plugin will automatically detect:
|
|
99 |
|
100 |
== Changelog ==
|
101 |
|
|
|
|
|
|
|
|
|
102 |
= 1.15.9 =
|
103 |
* You can now export data from BuddyPress fields
|
104 |
|
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.1
|
7 |
+
Stable tag: 1.15.9.1
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
99 |
|
100 |
== Changelog ==
|
101 |
|
102 |
+
= 1.15.9.1 =
|
103 |
+
* You can now export data from BuddyPress groups
|
104 |
+
* BuddyPress addon is now a class instead of different methods
|
105 |
+
|
106 |
= 1.15.9 =
|
107 |
* You can now export data from BuddyPress fields
|
108 |
|