Version Description
- New feature added actions, now you can assign posts while you are importing users
- Code improvements
Download this release
Release Info
Developer | carazo |
Plugin | Import users from CSV with meta |
Version | 1.17.3 |
Comparing to | |
See all releases |
Code changes from version 1.17.2.1 to 1.17.3
- addons/wpum-groups.php +33 -0
- classes/actions.php +95 -0
- classes/import.php +7 -9
- import-users-from-csv-with-meta.php +1 -1
- readme.txt +5 -1
addons/wpum-groups.php
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if ( ! defined( 'ABSPATH' ) ) exit;
|
4 |
+
|
5 |
+
if( !is_plugin_active( 'wpum-groups/wpum-groups.php' ) ){
|
6 |
+
return;
|
7 |
+
}
|
8 |
+
|
9 |
+
class ACUI_WPUM_Groups{
|
10 |
+
function __construct(){
|
11 |
+
}
|
12 |
+
|
13 |
+
function hooks(){
|
14 |
+
add_action( 'post_acui_import_single_user', array( $this, 'assign_group' ), 10, 7 );
|
15 |
+
}
|
16 |
+
|
17 |
+
function assign_group( $headers, $data, $user_id, $role, $positions, $form_data, $is_frontend ){
|
18 |
+
if( !$is_frontend )
|
19 |
+
return;
|
20 |
+
|
21 |
+
$group_ids = wpumgrp_get_user_group_ids( get_current_user_id() );
|
22 |
+
if( empty( $group_ids ) )
|
23 |
+
return;
|
24 |
+
|
25 |
+
foreach( $group_ids as $group_id ){
|
26 |
+
wpumgp_join_group( $group_id, $user_id );
|
27 |
+
wpumgr_approve_group_member( $group_id, $user_id );
|
28 |
+
}
|
29 |
+
}
|
30 |
+
}
|
31 |
+
|
32 |
+
$acui_wpum_groups = new ACUI_WPUM_Groups();
|
33 |
+
$acui_wpum_groups->hooks();
|
classes/actions.php
ADDED
@@ -0,0 +1,95 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
if ( ! defined( 'ABSPATH' ) ) exit;
|
3 |
+
|
4 |
+
class ACUI_Actions{
|
5 |
+
var $prefix;
|
6 |
+
var $registered;
|
7 |
+
|
8 |
+
function __construct(){
|
9 |
+
$this->prefix = '#action_';
|
10 |
+
$this->registered = array( 'assign_post' );
|
11 |
+
}
|
12 |
+
|
13 |
+
function hooks(){
|
14 |
+
add_filter( 'acui_restricted_fields', array( $this, 'restricted_fields' ) );
|
15 |
+
add_action( 'acui_documentation_after_plugins_activated', array( $this, 'documentation' ) );
|
16 |
+
|
17 |
+
foreach( $this->registered as $registered_action ){
|
18 |
+
add_action( 'acui_action_' . $registered_action, array( $this, $registered_action ), 10, 6 );
|
19 |
+
}
|
20 |
+
|
21 |
+
add_action( 'post_acui_import_single_user', array( $this, 'run' ), 10, 8 );
|
22 |
+
}
|
23 |
+
|
24 |
+
function check_prefix( $header ){
|
25 |
+
return ( substr( $header, 0, strlen( $this->prefix ) ) === $this->prefix );
|
26 |
+
}
|
27 |
+
|
28 |
+
function remove_prefix( $header ){
|
29 |
+
return substr( $header, strlen( $this->prefix ) );
|
30 |
+
}
|
31 |
+
|
32 |
+
function restricted_fields( $fields ){
|
33 |
+
$actions = array();
|
34 |
+
foreach( $this->registered as $registered_action )
|
35 |
+
$actions[] = $this->prefix . $registered_action;
|
36 |
+
|
37 |
+
return array_merge( $fields, $actions );
|
38 |
+
}
|
39 |
+
|
40 |
+
function run( $headers, $data, $user_id, $role, $positions, $form_data, $is_frontend, $is_cron ){
|
41 |
+
$actions = $this->get_actions_from_headers( $headers );
|
42 |
+
|
43 |
+
if( empty( $actions ) )
|
44 |
+
return;
|
45 |
+
|
46 |
+
foreach( $actions as $pos => $action ){
|
47 |
+
do_action( 'acui_action_' . $action, $user_id, $role, $data[ $pos ], $form_data, $is_frontend, $is_cron );
|
48 |
+
}
|
49 |
+
}
|
50 |
+
|
51 |
+
function get_actions_from_headers( $headers ){
|
52 |
+
$actions = array();
|
53 |
+
|
54 |
+
foreach( $headers as $pos => $header ){
|
55 |
+
if( $this->is_action( $header ) )
|
56 |
+
$actions[ $pos ] = $this->remove_prefix( $header );
|
57 |
+
}
|
58 |
+
|
59 |
+
return $actions;
|
60 |
+
}
|
61 |
+
|
62 |
+
function is_action( $header ){
|
63 |
+
if( !$this->check_prefix( $header ) )
|
64 |
+
return false;
|
65 |
+
|
66 |
+
return in_array( $this->remove_prefix( $header ), $this->registered );
|
67 |
+
}
|
68 |
+
|
69 |
+
function documentation(){
|
70 |
+
?>
|
71 |
+
<tr valign="top">
|
72 |
+
<th scope="row"><?php _e( 'Actions', 'import-users-from-csv-with-meta' ); ?></th>
|
73 |
+
<td><?php _e( 'You can do some actions while you are importing. You have to name the column as indicated below and follow the instructions:', 'import-users-from-csv-with-meta' ); ?>
|
74 |
+
<ul style="list-style:disc outside none;margin-left:2em;">
|
75 |
+
<li><strong>#action_assign_post</strong>: <?php _e( 'Within each cell, you must indicate the post_id that will be assigned to this user. You can use a list separating each ID by commas. The post can be of any post type.', 'import-users-from-csv-with-meta' ); ?></li>
|
76 |
+
</ul>
|
77 |
+
</td>
|
78 |
+
</tr>
|
79 |
+
<?php
|
80 |
+
}
|
81 |
+
|
82 |
+
function assign_post( $user_id, $role, $data_cell, $form_data, $is_frontend, $is_cron ){
|
83 |
+
$post_ids = explode( ',', $data_cell );
|
84 |
+
|
85 |
+
foreach( $post_ids as $post_id ){
|
86 |
+
wp_update_post( array(
|
87 |
+
'ID' => intval( $post_id ),
|
88 |
+
'post_author' => $user_id,
|
89 |
+
) );
|
90 |
+
}
|
91 |
+
}
|
92 |
+
}
|
93 |
+
|
94 |
+
$acui_actions = new ACUI_Actions();
|
95 |
+
$acui_actions->hooks();
|
classes/import.php
CHANGED
@@ -170,9 +170,7 @@ class ACUI_Import{
|
|
170 |
do_action( 'before_acui_import_users' );
|
171 |
|
172 |
$acui_helper = new ACUI_Helper();
|
173 |
-
$
|
174 |
-
$acui_not_meta_fields = $acui_helper->get_not_meta_fields();
|
175 |
-
$acui_restricted_fields = $acui_helper->get_restricted_fields();
|
176 |
$all_roles = array_keys( wp_roles()->roles );
|
177 |
$editable_roles = array_keys( get_editable_roles() );
|
178 |
|
@@ -267,17 +265,17 @@ class ACUI_Import{
|
|
267 |
$password_position = false;
|
268 |
$id_position = false;
|
269 |
|
270 |
-
foreach ( $
|
271 |
$positions[ $acui_restricted_field ] = false;
|
272 |
}
|
273 |
|
274 |
foreach( $data as $element ){
|
275 |
$headers[] = $element;
|
276 |
|
277 |
-
if( in_array( strtolower( $element ) , $
|
278 |
$positions[ strtolower( $element ) ] = $i;
|
279 |
|
280 |
-
if( !in_array( strtolower( $element ), $
|
281 |
$headers_filtered[] = $element;
|
282 |
|
283 |
$i++;
|
@@ -493,7 +491,7 @@ class ACUI_Import{
|
|
493 |
if( is_array( $role ) ){
|
494 |
foreach ($role as $single_role) {
|
495 |
$user_object->add_role( $single_role );
|
496 |
-
}
|
497 |
}
|
498 |
else{
|
499 |
$user_object->add_role( $role );
|
@@ -565,7 +563,7 @@ class ACUI_Import{
|
|
565 |
wp_cache_delete( $user_id, 'users' );
|
566 |
continue;
|
567 |
}
|
568 |
-
elseif( in_array( $headers[ $i ], $
|
569 |
if( $data[ $i ] === '' && $empty_cell_action == "leave" ){
|
570 |
continue;
|
571 |
}
|
@@ -574,7 +572,7 @@ class ACUI_Import{
|
|
574 |
continue;
|
575 |
}
|
576 |
}
|
577 |
-
elseif( in_array( $headers[ $i ], $
|
578 |
continue;
|
579 |
}
|
580 |
else{
|
170 |
do_action( 'before_acui_import_users' );
|
171 |
|
172 |
$acui_helper = new ACUI_Helper();
|
173 |
+
$restricted_fields = $acui_helper->get_restricted_fields();
|
|
|
|
|
174 |
$all_roles = array_keys( wp_roles()->roles );
|
175 |
$editable_roles = array_keys( get_editable_roles() );
|
176 |
|
265 |
$password_position = false;
|
266 |
$id_position = false;
|
267 |
|
268 |
+
foreach ( $restricted_fields as $acui_restricted_field ) {
|
269 |
$positions[ $acui_restricted_field ] = false;
|
270 |
}
|
271 |
|
272 |
foreach( $data as $element ){
|
273 |
$headers[] = $element;
|
274 |
|
275 |
+
if( in_array( strtolower( $element ) , $restricted_fields ) )
|
276 |
$positions[ strtolower( $element ) ] = $i;
|
277 |
|
278 |
+
if( !in_array( strtolower( $element ), $restricted_fields ) )
|
279 |
$headers_filtered[] = $element;
|
280 |
|
281 |
$i++;
|
491 |
if( is_array( $role ) ){
|
492 |
foreach ($role as $single_role) {
|
493 |
$user_object->add_role( $single_role );
|
494 |
+
}
|
495 |
}
|
496 |
else{
|
497 |
$user_object->add_role( $role );
|
563 |
wp_cache_delete( $user_id, 'users' );
|
564 |
continue;
|
565 |
}
|
566 |
+
elseif( in_array( $headers[ $i ], $acui_helper->get_wp_users_fields() ) ){ // wp_user data
|
567 |
if( $data[ $i ] === '' && $empty_cell_action == "leave" ){
|
568 |
continue;
|
569 |
}
|
572 |
continue;
|
573 |
}
|
574 |
}
|
575 |
+
elseif( in_array( $headers[ $i ], $acui_helper->get_not_meta_fields() ) ){
|
576 |
continue;
|
577 |
}
|
578 |
else{
|
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.17.
|
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.17.3
|
7 |
Author: codection
|
8 |
Author URI: https://codection.com
|
9 |
License: GPL2
|
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.6
|
7 |
-
Stable tag: 1.17.
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -103,6 +103,10 @@ Plugin will automatically detect:
|
|
103 |
|
104 |
== Changelog ==
|
105 |
|
|
|
|
|
|
|
|
|
106 |
= 1.17.2.1 =
|
107 |
* Addon included for WP User Manager - WPUM Groups
|
108 |
* BuddyPress addon improved
|
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.6
|
7 |
+
Stable tag: 1.17.3
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
103 |
|
104 |
== Changelog ==
|
105 |
|
106 |
+
= 1.17.3 =
|
107 |
+
* New feature added actions, now you can assign posts while you are importing users
|
108 |
+
* Code improvements
|
109 |
+
|
110 |
= 1.17.2.1 =
|
111 |
* Addon included for WP User Manager - WPUM Groups
|
112 |
* BuddyPress addon improved
|