Version Description
- A non-user admin could delete himself automatically deleting users not present in CSV (thanks again to @nonprofitweb https://wordpress.org/support/topic/non-admin-user-can-delete-self/#post-12950734)
- Improved "Users only can import users with a role that they allowed to edit" thanks also to @nonprofitweb
- Forms has now classes to be able to customize the way they are shown using CSV thanks again to @nonprofitweb
Download this release
Release Info
Developer | carazo |
Plugin | Import users from CSV with meta |
Version | 1.15.6.7 |
Comparing to | |
See all releases |
Code changes from version 1.15.6.6 to 1.15.6.7
- classes/export.php +10 -10
- classes/homepage.php +25 -25
- import-users-from-csv-with-meta.php +1 -1
- importer.php +10 -1
- readme.txt +6 -1
classes/export.php
CHANGED
@@ -18,11 +18,11 @@ class ACUI_Exporter{
|
|
18 |
public static function admin_gui(){
|
19 |
$roles = acui_get_editable_roles();
|
20 |
?>
|
21 |
-
<h3><?php _e( 'Export users', 'import-users-from-csv-with-meta' ); ?></h3>
|
22 |
-
<form method="POST" target="_blank" enctype="multipart/form-data" action="<?php echo admin_url( 'admin-ajax.php' ); ?>">
|
23 |
<table class="form-table">
|
24 |
<tbody>
|
25 |
-
<tr valign="top">
|
26 |
<th scope="row"><?php _e( 'Role', 'import-users-from-csv-with-meta' ); ?></th>
|
27 |
<td>
|
28 |
<select name="role">
|
@@ -33,14 +33,14 @@ class ACUI_Exporter{
|
|
33 |
</select>
|
34 |
</td>
|
35 |
</tr>
|
36 |
-
<tr valign="top">
|
37 |
<th scope="row"><?php _e( 'User created', 'import-users-from-csv-with-meta' ); ?></th>
|
38 |
<td>
|
39 |
-
<label>from <input name="from" type="date" value=""/></label>
|
40 |
-
<label>to <input name="to" type="date" value=""/></label>
|
41 |
</td>
|
42 |
</tr>
|
43 |
-
<tr valign="top">
|
44 |
<th scope="row"><?php _e( 'Delimiter', 'import-users-from-csv-with-meta' ); ?></th>
|
45 |
<td>
|
46 |
<select name="delimiter">
|
@@ -51,21 +51,21 @@ class ACUI_Exporter{
|
|
51 |
</select>
|
52 |
</td>
|
53 |
</tr>
|
54 |
-
<tr valign="top">
|
55 |
<th scope="row"><?php _e( 'Convert timestamp data to date format', 'import-users-from-csv-with-meta' ); ?></th>
|
56 |
<td>
|
57 |
<input type="checkbox" name="convert_timestamp" value="1" checked="checked">
|
58 |
<span class="description"><?php _e( 'If you have problems and you get some value exported as a date that should not be converted to date, please deactivate this option. If this option is not activated, datetime format will be ignored.', 'import-users-from-csv-with-meta' ); ?></span>
|
59 |
</td>
|
60 |
</tr>
|
61 |
-
<tr valign="top">
|
62 |
<th scope="row"><?php _e( 'Datetime format', 'import-users-from-csv-with-meta' ); ?></th>
|
63 |
<td>
|
64 |
<input name="datetime_format" type="text" value="Y-m-d H:i:s"/>
|
65 |
<span class="description"><a href="https://www.php.net/manual/en/datetime.formats.php"><?php _e( 'accepted formats', 'import-users-from-csv-with-meta' ); ?></a></span>
|
66 |
</td>
|
67 |
</tr>
|
68 |
-
<tr valign="top">
|
69 |
<th scope="row"><?php _e( 'Download CSV file with users', 'import-users-from-csv-with-meta' ); ?></th>
|
70 |
<td>
|
71 |
<input class="button-primary" type="submit" value="<?php _e( 'Download', 'import-users-from-csv-with-meta'); ?>"/>
|
18 |
public static function admin_gui(){
|
19 |
$roles = acui_get_editable_roles();
|
20 |
?>
|
21 |
+
<h3 id="acui_export_users_header"><?php _e( 'Export users', 'import-users-from-csv-with-meta' ); ?></h3>
|
22 |
+
<form id="acui_export_users_wrapper" method="POST" target="_blank" enctype="multipart/form-data" action="<?php echo admin_url( 'admin-ajax.php' ); ?>">
|
23 |
<table class="form-table">
|
24 |
<tbody>
|
25 |
+
<tr id="acui_role_wrapper" valign="top">
|
26 |
<th scope="row"><?php _e( 'Role', 'import-users-from-csv-with-meta' ); ?></th>
|
27 |
<td>
|
28 |
<select name="role">
|
33 |
</select>
|
34 |
</td>
|
35 |
</tr>
|
36 |
+
<tr id="acui_user_created_wrapper" valign="top">
|
37 |
<th scope="row"><?php _e( 'User created', 'import-users-from-csv-with-meta' ); ?></th>
|
38 |
<td>
|
39 |
+
<label for="from">from <input name="from" type="date" value=""/></label>
|
40 |
+
<label for="to">to <input name="to" type="date" value=""/></label>
|
41 |
</td>
|
42 |
</tr>
|
43 |
+
<tr id="acui_delimiter_wrapper" valign="top">
|
44 |
<th scope="row"><?php _e( 'Delimiter', 'import-users-from-csv-with-meta' ); ?></th>
|
45 |
<td>
|
46 |
<select name="delimiter">
|
51 |
</select>
|
52 |
</td>
|
53 |
</tr>
|
54 |
+
<tr id="acui_timestamp_wrapper" valign="top">
|
55 |
<th scope="row"><?php _e( 'Convert timestamp data to date format', 'import-users-from-csv-with-meta' ); ?></th>
|
56 |
<td>
|
57 |
<input type="checkbox" name="convert_timestamp" value="1" checked="checked">
|
58 |
<span class="description"><?php _e( 'If you have problems and you get some value exported as a date that should not be converted to date, please deactivate this option. If this option is not activated, datetime format will be ignored.', 'import-users-from-csv-with-meta' ); ?></span>
|
59 |
</td>
|
60 |
</tr>
|
61 |
+
<tr id="acui_datetime_format_wrapper" valign="top">
|
62 |
<th scope="row"><?php _e( 'Datetime format', 'import-users-from-csv-with-meta' ); ?></th>
|
63 |
<td>
|
64 |
<input name="datetime_format" type="text" value="Y-m-d H:i:s"/>
|
65 |
<span class="description"><a href="https://www.php.net/manual/en/datetime.formats.php"><?php _e( 'accepted formats', 'import-users-from-csv-with-meta' ); ?></a></span>
|
66 |
</td>
|
67 |
</tr>
|
68 |
+
<tr id="acui_download_csv_wrapper" valign="top">
|
69 |
<th scope="row"><?php _e( 'Download CSV file with users', 'import-users-from-csv-with-meta' ); ?></th>
|
70 |
<td>
|
71 |
<input class="button-primary" type="submit" value="<?php _e( 'Download', 'import-users-from-csv-with-meta'); ?>"/>
|
classes/homepage.php
CHANGED
@@ -21,14 +21,14 @@ class ACUI_Homepage{
|
|
21 |
|
22 |
<div style="clear:both;"></div>
|
23 |
|
24 |
-
<div class="main_bar">
|
25 |
<form method="POST" enctype="multipart/form-data" action="" accept-charset="utf-8" onsubmit="return check();">
|
26 |
-
<h2><?php _e( 'File', 'import-users-from-csv-with-meta'); ?></h2>
|
27 |
-
<table class="form-table">
|
28 |
<tbody>
|
29 |
|
30 |
<tr class="form-field form-required">
|
31 |
-
<th scope="row"><label><?php _e( 'CSV file <span class="description">(required)</span></label>', 'import-users-from-csv-with-meta' ); ?></th>
|
32 |
<td>
|
33 |
<div id="upload_file">
|
34 |
<input type="file" name="uploadfile" id="uploadfile" size="35" class="uploadfile" />
|
@@ -43,8 +43,8 @@ class ACUI_Homepage{
|
|
43 |
</tbody>
|
44 |
</table>
|
45 |
|
46 |
-
<h2><?php _e( 'Roles', 'import-users-from-csv-with-meta'); ?></h2>
|
47 |
-
<table class="form-table">
|
48 |
<tbody>
|
49 |
<tr class="form-field">
|
50 |
<th scope="row"><label for="role"><?php _e( 'Default role', 'import-users-from-csv-with-meta' ); ?></label></th>
|
@@ -54,9 +54,9 @@ class ACUI_Homepage{
|
|
54 |
|
55 |
foreach ($list_roles as $key => $value) {
|
56 |
if( in_array( $key, $last_roles_used ) )
|
57 |
-
echo "<label style='margin-right:5px;'><input name='role[]' type='checkbox' checked='checked' value='$key'/>$value</label>";
|
58 |
else
|
59 |
-
echo "<label style='margin-right:5px;'><input name='role[]' type='checkbox' value='$key'/>$value</label>";
|
60 |
}
|
61 |
?>
|
62 |
|
@@ -66,11 +66,11 @@ class ACUI_Homepage{
|
|
66 |
</tbody>
|
67 |
</table>
|
68 |
|
69 |
-
<h2><?php _e( 'Options', 'import-users-from-csv-with-meta'); ?></h2>
|
70 |
-
<table class="form-table">
|
71 |
<tbody>
|
72 |
-
<tr class="form-field form-required">
|
73 |
-
<th scope="row"><label><?php _e( 'What should the plugin do with empty cells?', 'import-users-from-csv-with-meta' ); ?></label></th>
|
74 |
<td>
|
75 |
<select name="empty_cell_action">
|
76 |
<option value="leave"><?php _e( 'Leave the old value for this metadata', 'import-users-from-csv-with-meta' ); ?></option>
|
@@ -79,14 +79,14 @@ class ACUI_Homepage{
|
|
79 |
</td>
|
80 |
</tr>
|
81 |
|
82 |
-
<tr class="form-field">
|
83 |
<th scope="row"><label for="user_login"><?php _e( 'Send mail', 'import-users-from-csv-with-meta' ); ?></label></th>
|
84 |
<td>
|
85 |
-
<p>
|
86 |
<?php _e( 'Do you wish to send a mail with credentials and other data?', 'import-users-from-csv-with-meta' ); ?>
|
87 |
<input type="checkbox" name="sends_email" value="yes" <?php if( get_option( 'acui_manually_send_mail' ) ): ?> checked="checked" <?php endif; ?>>
|
88 |
</p>
|
89 |
-
<p>
|
90 |
<?php _e( 'Do you wish to send this mail also to users that are being updated? (not only to the one which are being created)', 'import-users-from-csv-with-meta' ); ?>
|
91 |
<input type="checkbox" name="send_email_updated" value="yes" <?php if( get_option( 'acui_manually_send_mail_updated' ) ): ?> checked="checked" <?php endif; ?>>
|
92 |
</p>
|
@@ -95,12 +95,12 @@ class ACUI_Homepage{
|
|
95 |
</tbody>
|
96 |
</table>
|
97 |
|
98 |
-
<h2><?php _e( 'Update users', 'import-users-from-csv-with-meta'); ?></h2>
|
99 |
|
100 |
-
<table class="form-table">
|
101 |
<tbody>
|
102 |
-
<tr class="form-field form-required">
|
103 |
-
<th scope="row"><label><?php _e( 'Update existing users?', 'import-users-from-csv-with-meta' ); ?></label></th>
|
104 |
<td>
|
105 |
<select name="update_existing_users">
|
106 |
<option value="yes"><?php _e( 'Yes', 'import-users-from-csv-with-meta' ); ?></option>
|
@@ -109,8 +109,8 @@ class ACUI_Homepage{
|
|
109 |
</td>
|
110 |
</tr>
|
111 |
|
112 |
-
<tr class="form-field form-required">
|
113 |
-
<th scope="row"><label><?php _e( 'Update roles for existing users?', 'import-users-from-csv-with-meta' ); ?></label></th>
|
114 |
<td>
|
115 |
<select name="update_roles_existing_users">
|
116 |
<option value="no"><?php _e( 'No', 'import-users-from-csv-with-meta' ); ?></option>
|
@@ -122,12 +122,12 @@ class ACUI_Homepage{
|
|
122 |
</tbody>
|
123 |
</table>
|
124 |
|
125 |
-
<h2><?php _e( 'Users not present in CSV file', 'import-users-from-csv-with-meta'); ?></h2>
|
126 |
|
127 |
-
<table class="form-table">
|
128 |
<tbody>
|
129 |
|
130 |
-
<tr class="form-field form-required">
|
131 |
<th scope="row"><label for="delete_users"><?php _e( 'Delete users that are not present in the CSV?', 'import-users-from-csv-with-meta' ); ?></label></th>
|
132 |
<td>
|
133 |
<div style="float:left; margin-top: 10px;">
|
@@ -149,7 +149,7 @@ class ACUI_Homepage{
|
|
149 |
</td>
|
150 |
</tr>
|
151 |
|
152 |
-
<tr class="form-field form-required">
|
153 |
<th scope="row"><label for="change_role_not_present"><?php _e( 'Change role of users that are not present in the CSV?', 'import-users-from-csv-with-meta' ); ?></label></th>
|
154 |
<td>
|
155 |
<div style="float:left; margin-top: 10px;">
|
21 |
|
22 |
<div style="clear:both;"></div>
|
23 |
|
24 |
+
<div id="acui_form_wrapper" class="main_bar">
|
25 |
<form method="POST" enctype="multipart/form-data" action="" accept-charset="utf-8" onsubmit="return check();">
|
26 |
+
<h2 id="acui_file_header"><?php _e( 'File', 'import-users-from-csv-with-meta'); ?></h2>
|
27 |
+
<table id="acui_file_wrapper" class="form-table">
|
28 |
<tbody>
|
29 |
|
30 |
<tr class="form-field form-required">
|
31 |
+
<th scope="row"><label for="uploadfile"><?php _e( 'CSV file <span class="description">(required)</span></label>', 'import-users-from-csv-with-meta' ); ?></th>
|
32 |
<td>
|
33 |
<div id="upload_file">
|
34 |
<input type="file" name="uploadfile" id="uploadfile" size="35" class="uploadfile" />
|
43 |
</tbody>
|
44 |
</table>
|
45 |
|
46 |
+
<h2 id="acui_roles_header"><?php _e( 'Roles', 'import-users-from-csv-with-meta'); ?></h2>
|
47 |
+
<table id="acui_roles_wrapper" class="form-table">
|
48 |
<tbody>
|
49 |
<tr class="form-field">
|
50 |
<th scope="row"><label for="role"><?php _e( 'Default role', 'import-users-from-csv-with-meta' ); ?></label></th>
|
54 |
|
55 |
foreach ($list_roles as $key => $value) {
|
56 |
if( in_array( $key, $last_roles_used ) )
|
57 |
+
echo "<label id='$key' style='margin-right:5px;'><input name='role[]' type='checkbox' checked='checked' value='$key'/>$value</label>";
|
58 |
else
|
59 |
+
echo "<label id='$key' style='margin-right:5px;'><input name='role[]' type='checkbox' value='$key'/>$value</label>";
|
60 |
}
|
61 |
?>
|
62 |
|
66 |
</tbody>
|
67 |
</table>
|
68 |
|
69 |
+
<h2 id="acui_options_header"><?php _e( 'Options', 'import-users-from-csv-with-meta'); ?></h2>
|
70 |
+
<table id="acui_options_wrapper" class="form-table">
|
71 |
<tbody>
|
72 |
+
<tr id="acui_empty_cell_wrapper" class="form-field form-required">
|
73 |
+
<th scope="row"><label for="empty_cell_action"><?php _e( 'What should the plugin do with empty cells?', 'import-users-from-csv-with-meta' ); ?></label></th>
|
74 |
<td>
|
75 |
<select name="empty_cell_action">
|
76 |
<option value="leave"><?php _e( 'Leave the old value for this metadata', 'import-users-from-csv-with-meta' ); ?></option>
|
79 |
</td>
|
80 |
</tr>
|
81 |
|
82 |
+
<tr id="acui_send_email_wrapper" class="form-field">
|
83 |
<th scope="row"><label for="user_login"><?php _e( 'Send mail', 'import-users-from-csv-with-meta' ); ?></label></th>
|
84 |
<td>
|
85 |
+
<p id="sends_email_wrapper">
|
86 |
<?php _e( 'Do you wish to send a mail with credentials and other data?', 'import-users-from-csv-with-meta' ); ?>
|
87 |
<input type="checkbox" name="sends_email" value="yes" <?php if( get_option( 'acui_manually_send_mail' ) ): ?> checked="checked" <?php endif; ?>>
|
88 |
</p>
|
89 |
+
<p id="send_email_updated_wrapper">
|
90 |
<?php _e( 'Do you wish to send this mail also to users that are being updated? (not only to the one which are being created)', 'import-users-from-csv-with-meta' ); ?>
|
91 |
<input type="checkbox" name="send_email_updated" value="yes" <?php if( get_option( 'acui_manually_send_mail_updated' ) ): ?> checked="checked" <?php endif; ?>>
|
92 |
</p>
|
95 |
</tbody>
|
96 |
</table>
|
97 |
|
98 |
+
<h2 id="acui_update_users_header"><?php _e( 'Update users', 'import-users-from-csv-with-meta'); ?></h2>
|
99 |
|
100 |
+
<table id="acui_update_users_wrapper" class="form-table">
|
101 |
<tbody>
|
102 |
+
<tr id="acui_update_existing_users_wrapper" class="form-field form-required">
|
103 |
+
<th scope="row"><label for="update_existing_users"><?php _e( 'Update existing users?', 'import-users-from-csv-with-meta' ); ?></label></th>
|
104 |
<td>
|
105 |
<select name="update_existing_users">
|
106 |
<option value="yes"><?php _e( 'Yes', 'import-users-from-csv-with-meta' ); ?></option>
|
109 |
</td>
|
110 |
</tr>
|
111 |
|
112 |
+
<tr id="acui_update_roles_existing_users_wrapper" class="form-field form-required">
|
113 |
+
<th scope="row"><label for="update_roles_existing_users"><?php _e( 'Update roles for existing users?', 'import-users-from-csv-with-meta' ); ?></label></th>
|
114 |
<td>
|
115 |
<select name="update_roles_existing_users">
|
116 |
<option value="no"><?php _e( 'No', 'import-users-from-csv-with-meta' ); ?></option>
|
122 |
</tbody>
|
123 |
</table>
|
124 |
|
125 |
+
<h2 id="acui_users_not_present_header"><?php _e( 'Users not present in CSV file', 'import-users-from-csv-with-meta'); ?></h2>
|
126 |
|
127 |
+
<table id="acui_users_not_present_wrapper" class="form-table">
|
128 |
<tbody>
|
129 |
|
130 |
+
<tr id="acui_delete_users_wrapper" class="form-field form-required">
|
131 |
<th scope="row"><label for="delete_users"><?php _e( 'Delete users that are not present in the CSV?', 'import-users-from-csv-with-meta' ); ?></label></th>
|
132 |
<td>
|
133 |
<div style="float:left; margin-top: 10px;">
|
149 |
</td>
|
150 |
</tr>
|
151 |
|
152 |
+
<tr id="acui_not_present_wrapper" class="form-field form-required">
|
153 |
<th scope="row"><label for="change_role_not_present"><?php _e( 'Change role of users that are not present in the CSV?', 'import-users-from-csv-with-meta' ); ?></label></th>
|
154 |
<td>
|
155 |
<div style="float:left; margin-top: 10px;">
|
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.6.
|
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.6.7
|
7 |
Author: codection
|
8 |
Author URI: https://codection.com
|
9 |
License: GPL2
|
importer.php
CHANGED
@@ -698,9 +698,18 @@ function acui_import_users( $file, $form_data, $attach_id = 0, $is_cron = false,
|
|
698 |
if( $delete_users_flag ):
|
699 |
require_once( ABSPATH . 'wp-admin/includes/user.php');
|
700 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
701 |
$args = array(
|
702 |
'fields' => array( 'ID' ),
|
703 |
-
'role__not_in' =>
|
|
|
704 |
);
|
705 |
|
706 |
if( $delete_users_only_specified_role ){
|
698 |
if( $delete_users_flag ):
|
699 |
require_once( ABSPATH . 'wp-admin/includes/user.php');
|
700 |
|
701 |
+
global $wp_roles; // get all roles
|
702 |
+
$all_roles = $wp_roles->roles;
|
703 |
+
$exclude_roles = array_diff( array_keys( $all_roles ), $editable_roles ); // remove editable roles
|
704 |
+
|
705 |
+
if ( !in_array( 'administrator', $exclude_roles )){ // just to be sure
|
706 |
+
$exclude_roles[] = 'administrator';
|
707 |
+
}
|
708 |
+
|
709 |
$args = array(
|
710 |
'fields' => array( 'ID' ),
|
711 |
+
'role__not_in' => $exclude_roles,
|
712 |
+
'exclude' => array( get_current_user_id() ), // current user never cannot be deleted
|
713 |
);
|
714 |
|
715 |
if( $delete_users_only_specified_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.4.1
|
7 |
-
Stable tag: 1.15.6.
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -99,6 +99,11 @@ Plugin will automatically detect:
|
|
99 |
|
100 |
== Changelog ==
|
101 |
|
|
|
|
|
|
|
|
|
|
|
102 |
= 1.15.6.6 =
|
103 |
* Added multiple hooks to filter all about emails being sent when importing
|
104 |
* Included new variables in hooks that already exists in emails being sent when importing
|
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.4.1
|
7 |
+
Stable tag: 1.15.6.7
|
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.6.7 =
|
103 |
+
* A non-user admin could delete himself automatically deleting users not present in CSV (thanks again to @nonprofitweb https://wordpress.org/support/topic/non-admin-user-can-delete-self/#post-12950734)
|
104 |
+
* Improved "Users only can import users with a role that they allowed to edit" thanks also to @nonprofitweb
|
105 |
+
* Forms has now classes to be able to customize the way they are shown using CSV thanks again to @nonprofitweb
|
106 |
+
|
107 |
= 1.15.6.6 =
|
108 |
* Added multiple hooks to filter all about emails being sent when importing
|
109 |
* Included new variables in hooks that already exists in emails being sent when importing
|