Import users from CSV with meta - Version 1.12.2

Version Description

  • Extra check to avoid problems with CSV bad formed
  • Plugin can now manage attachments in email sending and email templates thanks to Immersedtechnologies
  • Part of the code has been rewritten using classes
  • We have changed the way of detecting the delimiter (thanks to @chaskinsuk https://wordpress.org/support/topic/detect-delimiter-fails-with-serialized-data/)
Download this release

Release Info

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

Code changes from version 1.12.1 to 1.12.2

classes/columns.php ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) exit;
4
+
5
+ class ACUI_Columns{
6
+ public static function admin_gui(){
7
+ $show_profile_fields = get_option( "acui_show_profile_fields");
8
+ $headers = get_option("acui_columns");
9
+ ?>
10
+ <h3><?php _e( 'Extra profile fields', 'import-users-from-csv-with-meta' ); ?></h3>
11
+ <table class="form-table">
12
+ <tbody>
13
+ <tr valign="top">
14
+ <th scope="row"><?php _e( 'Show fields in profile?', 'import-users-from-csv-with-meta' ); ?></th>
15
+ <td>
16
+ <form method="POST" enctype="multipart/form-data" action="" accept-charset="utf-8">
17
+ <input type="checkbox" name="show-profile-fields" value="yes" <?php if( $show_profile_fields == true ) echo "checked='checked'"; ?>>
18
+ <input type="hidden" name="show-profile-fields-action" value="update"/>
19
+ <input class="button-primary" type="submit" value="<?php _e( 'Save option', 'import-users-from-csv-with-meta'); ?>"/>
20
+ </form>
21
+ </td>
22
+ </tr>
23
+ <tr valign="top">
24
+ <th scope="row"><?php _e( 'Extra profile fields loadad in previous files', 'import-users-from-csv-with-meta' ); ?></th>
25
+ <td><small><em><?php _e( '(if you load another CSV with different columns, the new ones will replace this list)', 'import-users-from-csv-with-meta' ); ?></em></small>
26
+ <ol>
27
+ <?php
28
+ if( is_array( $headers ) && count( $headers ) > 0 ):
29
+ foreach ($headers as $column): ?>
30
+ <li><?php echo $column; ?></li>
31
+ <?php endforeach; ?>
32
+
33
+ <?php else: ?>
34
+ <li><?php _e( 'There is no columns loaded yet', 'import-users-from-csv-with-meta' ); ?></li>
35
+ <?php endif; ?>
36
+ </ol>
37
+ </td>
38
+ </tr>
39
+ </tbody>
40
+ </table>
41
+ <?php
42
+ }
43
+ }
classes/cron.php ADDED
@@ -0,0 +1,244 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) exit;
4
+
5
+ class ACUI_Cron{
6
+ public static function admin_gui(){
7
+ $cron_activated = get_option( "acui_cron_activated");
8
+ $send_mail_cron = get_option( "acui_cron_send_mail");
9
+ $send_mail_updated = get_option( "acui_cron_send_mail_updated");
10
+ $cron_delete_users = get_option( "acui_cron_delete_users");
11
+ $cron_delete_users_assign_posts = get_option( "acui_cron_delete_users_assign_posts");
12
+ $path_to_file = get_option( "acui_cron_path_to_file");
13
+ $period = get_option( "acui_cron_period");
14
+ $role = get_option( "acui_cron_role");
15
+ $update_roles_existing_users = get_option( "acui_cron_update_roles_existing_users");
16
+ $move_file_cron = get_option( "acui_move_file_cron");
17
+ $path_to_move = get_option( "acui_cron_path_to_move");
18
+ $path_to_move_auto_rename = get_option( "acui_cron_path_to_move_auto_rename");
19
+ $log = get_option( "acui_cron_log");
20
+ $allow_multiple_accounts = get_option("acui_cron_allow_multiple_accounts");
21
+ $loaded_periods = wp_get_schedules();
22
+
23
+ if( empty( $cron_activated ) )
24
+ $cron_activated = false;
25
+
26
+ if( empty( $send_mail_cron ) )
27
+ $send_mail_cron = false;
28
+
29
+ if( empty( $send_mail_updated ) )
30
+ $send_mail_updated = false;
31
+
32
+ if( empty( $cron_delete_users ) )
33
+ $cron_delete_users = false;
34
+
35
+ if( empty( $update_roles_existing_users) )
36
+ $update_roles_existing_users = false;
37
+
38
+ if( empty( $cron_delete_users_assign_posts ) )
39
+ $cron_delete_users_assign_posts = '';
40
+
41
+ if( empty( $path_to_file ) )
42
+ $path_to_file = dirname( __FILE__ ) . '/test.csv';
43
+
44
+ if( empty( $period ) )
45
+ $period = 'hourly';
46
+
47
+ if( empty( $move_file_cron ) )
48
+ $move_file_cron = false;
49
+
50
+ if( empty( $path_to_move ) )
51
+ $path_to_move = dirname( __FILE__ ) . '/move.csv';
52
+
53
+ if( empty( $path_to_move_auto_rename ) )
54
+ $path_to_move_auto_rename = false;
55
+
56
+ if( empty( $log ) )
57
+ $log = "No tasks done yet.";
58
+
59
+ if( empty( $allow_multiple_accounts ) )
60
+ $allow_multiple_accounts = "not_allowed";
61
+ ?>
62
+ <h3><?php _e( "Execute an import of users periodically", 'import-users-from-csv-with-meta' ); ?></h3>
63
+
64
+ <form method="POST" enctype="multipart/form-data" action="" accept-charset="utf-8">
65
+ <table class="form-table">
66
+ <tbody>
67
+ <tr class="form-field">
68
+ <th scope="row"><label for="path_to_file"><?php _e( "Path of file that are going to be imported", 'import-users-from-csv-with-meta' ); ?></label></th>
69
+ <td>
70
+ <input placeholder="<?php _e('Insert complete path to the file', 'import-users-from-csv-with-meta' ) ?>" type="text" name="path_to_file" id="path_to_file" value="<?php echo $path_to_file; ?>" style="width:70%;" />
71
+ <p class="description"><?php _e( 'You have to introduce the path to file, i.e.:', 'import-users-from-csv-with-meta' ); ?> <?php $upload_dir = wp_upload_dir(); echo $upload_dir["path"]; ?>/test.csv</p>
72
+ </td>
73
+ </tr>
74
+ <tr class="form-field form-required">
75
+ <th scope="row"><label for="period"><?php _e( 'Period', 'import-users-from-csv-with-meta' ); ?></label></th>
76
+ <td>
77
+ <select id="period" name="period">
78
+ <?php foreach( $loaded_periods as $key => $value ): ?>
79
+ <option <?php if( $period == $key ) echo "selected='selected'"; ?> value="<?php echo $key; ?>"><?php echo $value['display']; ?></option>
80
+ <?php endforeach; ?>
81
+ </select>
82
+ <p class="description"><?php _e( 'How often the event should reoccur?', 'import-users-from-csv-with-meta' ); ?></p>
83
+ </td>
84
+ </tr>
85
+ <tr class="form-field form-required">
86
+ <th scope="row"><label for="cron-activated"><?php _e( 'Activate periodical import?', 'import-users-from-csv-with-meta' ); ?></label></th>
87
+ <td>
88
+ <input type="checkbox" name="cron-activated" value="yes" <?php if( $cron_activated == true ) echo "checked='checked'"; ?>/>
89
+ </td>
90
+ </tr>
91
+ <tr class="form-field form-required">
92
+ <th scope="row"><label for="send-mail-cron"><?php _e( 'Send mail when using periodical import?', 'import-users-from-csv-with-meta' ); ?></label></th>
93
+ <td>
94
+ <input type="checkbox" name="send-mail-cron" value="yes" <?php if( $send_mail_cron == true ) echo "checked='checked'"; ?>/>
95
+ </td>
96
+ </tr>
97
+ <tr class="form-field form-required">
98
+ <th scope="row"><label for="send-mail-updated"><?php _e( 'Send mail also to users that are being updated?', 'import-users-from-csv-with-meta' ); ?></label></th>
99
+ <td>
100
+ <input type="checkbox" name="send-mail-updated" value="yes" <?php if( $send_mail_updated == true ) echo "checked='checked'"; ?>/>
101
+ </td>
102
+ </tr>
103
+
104
+ <?php if( is_plugin_active( 'allow-multiple-accounts/allow-multiple-accounts.php' ) ): ?>
105
+
106
+ <tr class="form-field form-required">
107
+ <th scope="row"><label><?php _e( 'Repeated email in different users?', 'import-users-from-csv-with-meta' ); ?></label></th>
108
+ <td>
109
+ <input type="checkbox" name="allow_multiple_accounts" value="yes" <?php if( $allow_multiple_accounts == "allowed" ) echo "checked='checked'"; ?>/>
110
+ <p class="description"><strong>(<?php _e( 'Only for', 'import-users-from-csv-with-meta' ); ?> <a href="https://wordpress.org/plugins/allow-multiple-accounts/"><?php _e( 'Allow Multiple Accounts', 'import-users-from-csv-with-meta' ); ?></a> <?php _e( 'users', 'import-users-from-csv-with-meta'); ?>)</strong>. <?php _e('Allow multiple user accounts to be created having the same email address.','import-users-from-csv-with-meta' ); ?></p>
111
+ </td>
112
+ </tr>
113
+
114
+ <?php endif; ?>
115
+
116
+ <tr class="form-field form-required">
117
+ <th scope="row"><label for="cron-delete-users"><?php _e( 'Delete users that are not present in the CSV?', 'import-users-from-csv-with-meta' ); ?></label></th>
118
+ <td>
119
+ <div style="float:left;">
120
+ <input type="checkbox" name="cron-delete-users" value="yes" <?php if( $cron_delete_users == true ) echo "checked='checked'"; ?>/>
121
+ </div>
122
+ <div style="margin-left:25px;">
123
+ <select id="cron-delete-users-assign-posts" name="cron-delete-users-assign-posts">
124
+ <?php
125
+ if( $cron_delete_users_assign_posts == '' )
126
+ echo "<option selected='selected' value=''>" . __( 'Delete posts of deled users without assing to any user', 'import-users-from-csv-with-meta' ) . "</option>";
127
+ else
128
+ echo "<option value=''>" . __( 'Delete posts of deled users without assing to any user', 'import-users-from-csv-with-meta' ) . "</option>";
129
+
130
+ $blogusers = get_users();
131
+
132
+ foreach ( $blogusers as $bloguser ) {
133
+ if( $bloguser->ID == $cron_delete_users_assign_posts )
134
+ echo "<option selected='selected' value='{$bloguser->ID}'>{$bloguser->display_name}</option>";
135
+ else
136
+ echo "<option value='{$bloguser->ID}'>{$bloguser->display_name}</option>";
137
+ }
138
+ ?>
139
+ </select>
140
+ <p class="description"><?php _e( 'After delete users, we can choose if we want to assign their posts to another user. Please do not delete them or posts will be deleted.', 'import-users-from-csv-with-meta' ); ?></p>
141
+ </div>
142
+ </td>
143
+ </tr>
144
+ <tr class="form-field form-required">
145
+ <th scope="row"><label for="role"><?php _e( 'Role', 'import-users-from-csv-with-meta' ); ?></label></th>
146
+ <td>
147
+ <select id="role" name="role">
148
+ <?php
149
+ if( $role == '' )
150
+ echo "<option selected='selected' value=''>" . __( 'Disable role assignement in cron import', 'import-users-from-csv-with-meta' ) . "</option>";
151
+ else
152
+ echo "<option value=''>" . __( 'Disable role assignement in cron import', 'import-users-from-csv-with-meta' ) . "</option>";
153
+
154
+ $list_roles = acui_get_editable_roles();
155
+ foreach ($list_roles as $key => $value) {
156
+ if($key == $role)
157
+ echo "<option selected='selected' value='$key'>$value</option>";
158
+ else
159
+ echo "<option value='$key'>$value</option>";
160
+ }
161
+ ?>
162
+ </select>
163
+ <p class="description"><?php _e( 'Which role would be used to import users?', 'import-users-from-csv-with-meta' ); ?></p>
164
+ </td>
165
+ </tr>
166
+ <tr class="form-field form-required">
167
+ <th scope="row"><label for="update-roles-existing-users"><?php _e( 'Update roles for existing users?', 'import-users-from-csv-with-meta' ); ?></label></th>
168
+ <td>
169
+ <input type="checkbox" name="update-roles-existing-users" value="yes" <?php if( $update_roles_existing_users == 'yes' ) echo "checked='checked'"; ?>/>
170
+ </td>
171
+ </tr>
172
+
173
+ <tr class="form-field form-required">
174
+ <th scope="row"><label for="move-file-cron"><?php _e( 'Move file after import?', 'import-users-from-csv-with-meta' ); ?></label></th>
175
+ <td>
176
+ <div style="float:left;">
177
+ <input type="checkbox" name="move-file-cron" value="yes" <?php if( $move_file_cron == true ) echo "checked='checked'"; ?>/>
178
+ </div>
179
+
180
+ <div class="move-file-cron-cell" style="margin-left:25px;">
181
+ <input placeholder="<?php _e( 'Insert complete path to the file', 'import-users-from-csv-with-meta'); ?>" type="text" name="path_to_move" id="path_to_move" value="<?php echo $path_to_move; ?>" style="width:70%;" />
182
+ <p class="description"><?php _e( 'You have to introduce the path to file, i.e.:', 'import-users-from-csv-with-meta'); ?> <?php $upload_dir = wp_upload_dir(); echo $upload_dir["path"]; ?>/move.csv</p>
183
+ </div>
184
+ </td>
185
+ </tr>
186
+ <tr class="form-field form-required move-file-cron-cell">
187
+ <th scope="row"><label for="move-file-cron"><?php _e( 'Auto rename after move?', 'import-users-from-csv-with-meta' ); ?></label></th>
188
+ <td>
189
+ <div style="float:left;">
190
+ <input type="checkbox" name="path_to_move_auto_rename" value="yes" <?php if( $path_to_move_auto_rename == true ) echo "checked='checked'"; ?>/>
191
+ </div>
192
+
193
+ <div style="margin-left:25px;">
194
+ <p class="description"><?php _e( 'Your file will be renamed after moved, so you will not lost any version of it. The way to rename will be append the time stamp using this date format: YmdHis.', 'import-users-from-csv-with-meta'); ?></p>
195
+ </div>
196
+ </td>
197
+ </tr>
198
+ <tr class="form-field form-required">
199
+ <th scope="row"><label for="log"><?php _e( 'Last actions of schedule task', 'import-users-from-csv-with-meta' ); ?></label></th>
200
+ <td>
201
+ <pre><?php echo $log; ?></pre>
202
+ </td>
203
+ </tr>
204
+ </tbody>
205
+ </table>
206
+ <input class="button-primary" type="submit" value="<?php _e( 'Save schedule options', 'import-users-from-csv-with-meta'); ?>"/>
207
+ </form>
208
+
209
+ <script>
210
+ jQuery( document ).ready( function( $ ){
211
+ $( "[name='cron-delete-users']" ).change(function() {
212
+ if( $(this).is( ":checked" ) ) {
213
+ var returnVal = confirm("<?php _e( 'Are you sure to delete all users that are not present in the CSV? This action cannot be undone.', 'import-users-from-csv-with-meta' ); ?>");
214
+ $(this).attr("checked", returnVal);
215
+
216
+ if( returnVal )
217
+ $( '#cron-delete-users-assign-posts' ).show();
218
+ }
219
+ else{
220
+ $( '#cron-delete-users-assign-posts' ).hide();
221
+ }
222
+ });
223
+
224
+ $( "[name='move-file-cron']" ).change(function() {
225
+ if( $(this).is( ":checked" ) ){
226
+ $( '.move-file-cron-cell' ).show();
227
+ }
228
+ else{
229
+ $( '.move-file-cron-cell' ).hide();
230
+ }
231
+ });
232
+
233
+ <?php if( $cron_delete_users == '' ): ?>
234
+ $( '#cron-delete-users-assign-posts' ).hide();
235
+ <?php endif; ?>
236
+
237
+ <?php if( !$move_file_cron ): ?>
238
+ $( '.move-file-cron-cell' ).hide();
239
+ <?php endif; ?>
240
+ });
241
+ </script>
242
+ <?php
243
+ }
244
+ }
classes/doc.php ADDED
@@ -0,0 +1,155 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) exit;
4
+
5
+ class ACUI_Doc{
6
+ public static function message(){
7
+ ?>
8
+ <h3><?php _e( 'Documentation', 'import-users-from-csv-with-meta' ); ?></h3>
9
+ <table class="form-table">
10
+ <tbody>
11
+ <tr valign="top">
12
+ <th scope="row"><?php _e( 'Columns position', 'import-users-from-csv-with-meta' ); ?></th>
13
+ <td><small><em><?php _e( '(Documents should look like the one presented into screenshot. Remember you should fill the first two columns with the next values)', 'import-users-from-csv-with-meta' ); ?></em></small>
14
+ <ol>
15
+ <li><?php _e( 'Username', 'import-users-from-csv-with-meta' ); ?></li>
16
+ <li><?php _e( 'Email', 'import-users-from-csv-with-meta' ); ?></li>
17
+ </ol>
18
+ <small><em><?php _e( '(The next columns are totally customizable and you can use whatever you want. All rows must contains same columns)', 'import-users-from-csv-with-meta' ); ?></em></small>
19
+ <small><em><?php _e( '(User profile will be adapted to the kind of data you have selected)', 'import-users-from-csv-with-meta' ); ?></em></small>
20
+ <small><em><?php _e( '(If you want to disable the extra profile information, please deactivate this plugin after make the import)', 'import-users-from-csv-with-meta' ); ?></em></small>
21
+ </td>
22
+ </tr>
23
+ <tr valign="top">
24
+ <th scope="row"><?php _e( 'id', 'import-users-from-csv-with-meta' ); ?></th>
25
+ <td><?php _e( 'You can use a column called id in order to make inserts or updates of an user using the ID used by WordPress in the wp_users table. We have two different cases:', 'import-users-from-csv-with-meta' ); ?>
26
+ <ul style="list-style:disc outside none; margin-left:2em;">
27
+ <li><?php _e( "If id <strong>doesn't exist in your users table</strong>: WordPress core does not allow us insert it, so it will throw an error of kind: invalid_user_id", 'import-users-from-csv-with-meta' ); ?></li>
28
+ <li><?php _e( "If id <strong>exists</strong>: plugin check if username is the same, if yes, it will update the data, if not, it ignores the cell to avoid problems", 'import-users-from-csv-with-meta' ); ?></li>
29
+ </ul>
30
+ </td>
31
+ </tr>
32
+ <tr valign="top">
33
+ <th scope="row"><?php _e( "Passwords", 'import-users-from-csv-with-meta' ); ?></th>
34
+ <td><?php _e( "A string that contains user passwords. We have different options for this case:", 'import-users-from-csv-with-meta' ); ?>
35
+ <ul style="list-style:disc outside none; margin-left:2em;">
36
+ <li><?php _e( "If you <strong>don't create a column for passwords</strong>: passwords will be generated automatically", 'import-users-from-csv-with-meta' ); ?></li>
37
+ <li><?php _e( "If you <strong>create a column for passwords</strong>: if cell is empty, password won't be updated; if cell has a value, it will be used", 'import-users-from-csv-with-meta' ); ?></li>
38
+ </ul>
39
+ </td>
40
+ </tr>
41
+ <tr valign="top">
42
+ <th scope="row"><?php _e( "Roles", 'import-users-from-csv-with-meta' ); ?></th>
43
+ <td><?php _e( "Plugin can import roles from the CSV. This is how it works:", 'import-users-from-csv-with-meta' ); ?>
44
+ <ul style="list-style:disc outside none; margin-left:2em;">
45
+ <li><?php _e( "If you <strong>don't create a column for roles</strong>: roles would be chosen from the 'Default role' field in import screen.", 'import-users-from-csv-with-meta' ); ?></li>
46
+ <li><?php _e( "If you <strong>create a column called 'role'</strong>: if cell is empty, roles would be chosen from 'Default role' field in import screen; if cell has a value, it will be used as role, if this role doesn't exist the default one would be used", 'import-users-from-csv-with-meta' ); ?></li>
47
+ <li><?php _e( "Multiple roles can be imported creating <strong>a list of roles</strong> using commas to separate values.", 'import-users-from-csv-with-meta' ); ?></li>
48
+ </ul>
49
+ <em><?php _e( "Notice: If the default new role is administrator in WordPress settings, role will not be set during a CSV file import with this plugin. Check it if all users are being imported as administrators and you have set another role in this plugin.", 'import-users-from-csv-with-meta' ); ?></em>
50
+ </td>
51
+ </tr>
52
+ <tr valign="top">
53
+ <th scope="row"><?php _e( "Serialized data", 'import-users-from-csv-with-meta' ); ?></th>
54
+ <td><?php _e( "Plugin can now import serialized data. You have to use the serialized string directly in the CSV cell in order the plugin will be able to understand it as an serialized data instead as any other string.", 'import-users-from-csv-with-meta' ); ?>
55
+ </td>
56
+ </tr>
57
+ <tr valign="top">
58
+ <th scope="row"><?php _e( "Lists", 'import-users-from-csv-with-meta' ); ?></th>
59
+ <td><?php _e( "Plugin can now import lists an array. Use this separator:", 'import-users-from-csv-with-meta'); ?> <strong>::</strong> <?php _e("two colons, inside the cell in order to split the string in a list of items.", 'import-users-from-csv-with-meta' ); ?>
60
+ </td>
61
+ </tr>
62
+ <tr valign="top">
63
+ <th scope="row"><?php _e( 'WordPress default profile data', 'import-users-from-csv-with-meta' ); ?></th>
64
+ <td><?php _e( "You can use those labels if you want to set data adapted to the WordPress default user columns (the ones who use the function", 'import-users-from-csv-with-meta' ); ?> <a href="http://codex.wordpress.org/Function_Reference/wp_update_user">wp_update_user</a>)
65
+ <ol>
66
+ <li><strong>user_nicename</strong>: <?php _e( "A string that contains a URL-friendly name for the user. The default is the user's username.", 'import-users-from-csv-with-meta' ); ?></li>
67
+ <li><strong>user_url</strong>: <?php _e( "A string containing the user's URL for the user's web site.", 'import-users-from-csv-with-meta' ); ?> </li>
68
+ <li><strong>display_name</strong>: <?php _e( "A string that will be shown on the site. Defaults to user's username. It is likely that you will want to change this, for both appearance and security through obscurity (that is if you don't use and delete the default admin user).", 'import-users-from-csv-with-meta' ); ?></li>
69
+ <li><strong>nickname</strong>: <?php _e( "The user's nickname, defaults to the user's username.", 'import-users-from-csv-with-meta' ); ?> </li>
70
+ <li><strong>first_name</strong>: <?php _e( "The user's first name.", 'import-users-from-csv-with-meta' ); ?></li>
71
+ <li><strong>last_name</strong>: <?php _e("The user's last name.", 'import-users-from-csv-with-meta' ); ?></li>
72
+ <li><strong>description</strong>: <?php _e("A string containing content about the user.", 'import-users-from-csv-with-meta' ); ?></li>
73
+ <li><strong>jabber</strong>: <?php _e("User's Jabber account.", 'import-users-from-csv-with-meta' ); ?></li>
74
+ <li><strong>aim</strong>: <?php _e("User's AOL IM account.", 'import-users-from-csv-with-meta' ); ?></li>
75
+ <li><strong>yim</strong>: <?php _e("User's Yahoo IM account.", 'import-users-from-csv-with-meta' ); ?></li>
76
+ <li><strong>user_registered</strong>: <?php _e( "Using the WordPress format for this kind of data Y-m-d H:i:s.", "import-users-from-csv-with-meta "); ?></li>
77
+ </ol>
78
+ </td>
79
+ </tr>
80
+
81
+ <?php if( is_plugin_active( 'woocommerce/woocommerce.php' ) ): ?>
82
+
83
+ <tr valign="top">
84
+ <th scope="row"><?php _e( "WooCommerce is activated", 'import-users-from-csv-with-meta' ); ?></th>
85
+ <td><?php _e( "You can use those labels if you want to set data adapted to the WooCommerce default user columns", 'import-users-from-csv-with-meta' ); ?>
86
+ <ol>
87
+ <li>billing_first_name</li>
88
+ <li>billing_last_name</li>
89
+ <li>billing_company</li>
90
+ <li>billing_address_1</li>
91
+ <li>billing_address_2</li>
92
+ <li>billing_city</li>
93
+ <li>billing_postcode</li>
94
+ <li>billing_country</li>
95
+ <li>billing_state</li>
96
+ <li>billing_phone</li>
97
+ <li>billing_email</li>
98
+ <li>shipping_first_name</li>
99
+ <li>shipping_last_name</li>
100
+ <li>shipping_company</li>
101
+ <li>shipping_address_1</li>
102
+ <li>shipping_address_2</li>
103
+ <li>shipping_city</li>
104
+ <li>shipping_postcode</li>
105
+ <li>shipping_country</li>
106
+ <li>shipping_state</li>
107
+ </ol>
108
+ </td>
109
+ </tr>
110
+ <?php endif; ?>
111
+
112
+ <?php if( is_plugin_active( 'buddypress/bp-loader.php' ) ): ?>
113
+
114
+ <tr valign="top">
115
+ <th scope="row"><?php _e( "BuddyPress is activated", 'import-users-from-csv-with-meta' ); ?></th>
116
+ <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' ); ?>
117
+ <ul style="list-style:disc outside none; margin-left:2em;">
118
+ <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>
119
+ <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>
120
+ <li><?php _e( "And the role assigned in this group: <em>Administrator, Moderator or Member</em>", 'import-users-from-csv-with-meta' ); ?></li>
121
+ <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>
122
+ <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>
123
+ <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>
124
+ </ul>
125
+ </td>
126
+ </tr>
127
+
128
+ <?php endif; ?>
129
+
130
+ <?php do_action( 'acui_documentation_after_plugins_activated' ); ?>
131
+
132
+ <tr valign="top">
133
+ <th scope="row"><?php _e( "Important notice", 'import-users-from-csv-with-meta' ); ?></th>
134
+ <td><?php _e( "You can upload as many files as you want, but all must have the same columns. If you upload another file, the columns will change to the form of last file uploaded.", 'import-users-from-csv-with-meta' ); ?></td>
135
+ </tr>
136
+ <tr valign="top">
137
+ <th scope="row"><?php _e( "Any question about it", 'import-users-from-csv-with-meta' ); ?></th>
138
+ <td>
139
+ <ul style="list-style:disc outside none; margin-left:2em;">
140
+ <li><?php _e( 'Free support (in WordPress forums):', 'import-users-from-csv-with-meta' ); ?> <a href="https://wordpress.org/support/plugin/import-users-from-csv-with-meta">https://wordpress.org/support/plugin/import-users-from-csv-with-meta</a>.</li>
141
+ <li><?php _e( 'Premium support (with a quote):', 'import-users-from-csv-with-meta' ); ?> <a href="mailto:contacto@codection.com">contacto@codection.com</a>.</li>
142
+ </ul>
143
+ </td>
144
+ </tr>
145
+ <tr valign="top">
146
+ <th scope="row"><?php _e( 'Example', 'import-users-from-csv-with-meta' ); ?></th>
147
+ <td><?php _e( 'Download this', 'import-users-from-csv-with-meta' ); ?> <a href="<?php echo plugins_url() . "/import-users-from-csv-with-meta/test.csv"; ?>">.csv <?php _e('file','import-users-from-csv-with-meta'); ?></a> <?php _e( 'to test', 'import-users-from-csv-with-meta' ); ?></td>
148
+ </tr>
149
+ </tbody>
150
+ </table>
151
+ <br/>
152
+ <div style="width:775px;margin:0 auto"><img src="<?php echo plugins_url() . "/import-users-from-csv-with-meta/csv_example.png"; ?>"/></div>
153
+ <?php
154
+ }
155
+ }
classes/donate.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) exit;
4
+
5
+ class ACUI_Donate{
6
+ public static function message(){
7
+ global $acui_url_plugin;
8
+ ?>
9
+ <div class="postbox">
10
+ <h3 class="hndle"><span>&nbsp;<?php _e( 'Do you like it?', 'import-users-from-csv-with-meta' ); ?></span></h3>
11
+
12
+ <div class="inside" style="display: block;">
13
+ <img src="<?php echo $acui_url_plugin; ?>icon_coffee.png" alt="<?php _e( 'buy me a coffee', 'import-users-from-csv-with-meta' ); ?>" style=" margin: 5px; float:left;">
14
+ <p><?php _e( 'Hi! we are', 'import-users-from-csv-with-meta'); ?> <a href="https://twitter.com/fjcarazo" target="_blank" title="Javier Carazo">Javier Carazo</a> <?php _e( 'and all the team of', 'import-users-from-csv-with-meta' ); ?> <a href="http://codection.com">Codection</a>, <?php _e("developers of this plugin.", 'import-users-from-csv-with-meta' ); ?></p>
15
+ <p><?php _e( 'We have been spending many hours to develop this plugin and answering questions in the forum to give you the best support. <br>If you like and use this plugin, you can <strong>buy us a cup of coffee</strong>.', 'import-users-from-csv-with-meta' ); ?></p>
16
+ <form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
17
+ <input type="hidden" name="cmd" value="_s-xclick">
18
+ <input type="hidden" name="hosted_button_id" value="QPYVWKJG4HDGG">
19
+ <input type="image" src="https://www.paypalobjects.com/en_GB/i/btn/btn_donate_LG.gif" border="0" name="submit" alt="<?php _e('PayPal – The safer, easier way to pay online.', 'import-users-from-csv-with-meta' ); ?>">
20
+ <img alt="" border="0" src="https://www.paypalobjects.com/es_ES/i/scr/pixel.gif" width="1" height="1">
21
+ </form>
22
+ <div style="clear:both;"></div>
23
+ </div>
24
+
25
+ <h3 class="hndle"><span>&nbsp;<?php _e( 'Or if you prefer, you can also help us becoming a Patreon:', 'import-users-from-csv-with-meta' ); ?></span></h3>
26
+
27
+ <div class="inside acui" style="display: block;">
28
+ <a class="patreon" color="primary" type="button" name="become-a-patron" data-tag="become-patron-button" href="https://www.patreon.com/bePatron?c=1741454" role="button">
29
+ <div class="oosjif-1 jFPfxp"><span>Become a patron</span></div>
30
+ </a>
31
+ </div>
32
+ </div>
33
+ <?php
34
+ }
35
+ }
classes/email-options.php ADDED
@@ -0,0 +1,123 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) exit;
4
+
5
+ class ACUI_Email_Options{
6
+ public static function admin_gui(){
7
+ $from_email = get_option( "acui_mail_from" );
8
+ $from_name = get_option( "acui_mail_from_name" );
9
+ $body_mail = get_option( "acui_mail_body" );
10
+ $subject_mail = get_option( "acui_mail_subject" );
11
+ $template_id = get_option( "acui_mail_template_id" );
12
+ $attachment_id = get_option( "acui_mail_attachment_id" );
13
+ $enable_email_templates = get_option( "acui_enable_email_templates" );
14
+ $automattic_wordpress_email = get_option( "acui_automattic_wordpress_email" );
15
+ ?>
16
+ <form method="POST" enctype="multipart/form-data" action="" accept-charset="utf-8">
17
+ <h3><?php _e('Mail options','import-users-from-csv-with-meta'); ?></h3>
18
+
19
+ <p class="description"><?php _e( 'You can set your own SMTP and other mail details', 'import-users-from-csv-with-meta' ); ?> <a href="<?php echo admin_url( 'tools.php?page=acui-smtp' ); ?>" target="_blank"><?php _e( 'here', 'import-users-from-csv-with-meta' ); ?></a>.
20
+
21
+ <table class="optiontable form-table">
22
+ <tbody>
23
+ <tr valign="top">
24
+ <th scope="row"><?php _e( 'WordPress automatic emails users updated', 'import-users-from-csv-with-meta' ); ?></th>
25
+ <td>
26
+ <fieldset>
27
+ <legend class="screen-reader-text">
28
+ <span><?php _e( 'Send automattic WordPress emails?', 'import-users-from-csv-with-meta' ); ?></span>
29
+ </legend>
30
+ <label for="automattic_wordpress_email">
31
+ <select name="automattic_wordpress_email" id="automattic_wordpress_email">
32
+ <option <?php if( $automattic_wordpress_email == 'false' ) echo "selected='selected'"; ?> value="false"><?php _e( "Deactivate WordPress automattic email when an user is updated or his password is changed", 'import-users-from-csv-with-meta' ) ;?></option>
33
+ <option <?php if( $automattic_wordpress_email == 'true' ) echo "selected='selected'"; ?> value="true"><?php _e( 'Activate WordPress automattic email when an user is updated or his password is changed', 'import-users-from-csv-with-meta' ); ?></option>
34
+ </select>
35
+ <span class="description"><? _e( "When you update an user or change his password, WordPress prepare and send automattic email, you can deactivate it here.", 'import-users-from-csv-with-meta' ); ?></span>
36
+ </label>
37
+ </fieldset>
38
+ </td>
39
+ </tr>
40
+ <tr valign="top">
41
+ <th scope="row"><?php _e( 'Enable mail templates:', 'import-users-from-csv-with-meta' ); ?></th>
42
+ <td>
43
+ <fieldset>
44
+ <legend class="screen-reader-text">
45
+ <span><?php _e( 'Do you want to enable mail templates?', 'import-users-from-csv-with-meta' ); ?></span>
46
+ </legend>
47
+ <label for="enable_email_templates">
48
+ <input id="enable_email_templates" name="enable_email_templates" value="yes" type="checkbox" <?php checked( $enable_email_templates ); ?>>
49
+ <span class="description"><? _e( "If you activate it, a new option in the menu will be created to store and manage mail templates, instead of using only the next one.", 'import-users-from-csv-with-meta' ); ?></span>
50
+ </label>
51
+ </fieldset>
52
+ </td>
53
+ </tr>
54
+ </tbody>
55
+ </table>
56
+
57
+ <?php if( $enable_email_templates && wp_count_posts( 'acui_email_template' )->publish > 0 ): ?>
58
+ <h3><?php _e( 'Load custom email from email templates', 'import-users-from-csv-with-meta' ); ?></h3>
59
+ <?php wp_dropdown_pages( array( 'id' => 'email_template_selected', 'post_type' => 'acui_email_template', 'selected' => $template_id ) ); ?>
60
+ <input id="load_email_template" class="button-primary" type="button" value="<?php _e( "Load subject and content from this email template", 'import-users-from-csv-with-meta' ); ?>"/>
61
+ <?php endif; ?>
62
+
63
+ <h3><?php _e( 'Customize the email that can be sent when importing users', 'import-users-from-csv-with-meta' ); ?></h3>
64
+
65
+ <p><?php _e( 'Mail subject :', 'import-users-from-csv-with-meta' ); ?><input name="subject_mail" size="100" value="<?php echo $subject_mail; ?>" id="title" autocomplete="off" type="text"></p>
66
+ <?php wp_editor( $body_mail, 'body_mail'); ?>
67
+ <input type="hidden" id="template_id" name="template_id" value="<?php echo $template_id; ?>"/>
68
+
69
+ <fieldset>
70
+ <div>
71
+ <label for="email_template_attachment_file"><?php _e( 'Attachment', 'import-users-from-csv-with-meta' )?></label><br>
72
+ <input type="url" class="large-text" name="email_template_attachment_file" id="email_template_attachment_file" value="<?php echo wp_get_attachment_url( $attachment_id ); ?>" readonly/><br>
73
+ <input type="hidden" name="email_template_attachment_id" id="email_template_attachment_id" value="<?php echo $attachment_id ?>"/>
74
+ <button type="button" class="button" id="acui_email_template_upload_button"><?php _e( 'Upload file', 'import-users-from-csv-with-meta' )?></button>
75
+ </div>
76
+ </fieldset>
77
+
78
+ <br/>
79
+ <input class="button-primary" type="submit" value="<?php _e( 'Save email template and options', 'import-users-from-csv-with-meta'); ?>" id="save_mail_template_options"/>
80
+
81
+ <?php ACUI_Email_Template::email_templates_edit_form_after_editor(); ?>
82
+
83
+ </form>
84
+
85
+ <script type="text/javascript">
86
+ jQuery( document ).ready( function( $ ){
87
+ $( '#enable_email_templates' ).change( function(){
88
+ var enable = $( this ).is( ':checked' );
89
+ var data = {
90
+ 'action': 'acui_refresh_enable_email_templates',
91
+ 'enable': enable,
92
+ 'security': '<?php echo wp_create_nonce( "codection-security" ); ?>',
93
+ };
94
+
95
+ $.post( ajaxurl, data, function( response ) {
96
+ location.reload();
97
+ });
98
+ } );
99
+
100
+ $( '#load_email_template' ).click( function(){
101
+ if( $( '#email_template_selected' ).val() == '' )
102
+ return;
103
+
104
+ var data = {
105
+ 'action': 'acui_email_template_selected',
106
+ 'email_template_selected': $( '#email_template_selected' ).val(),
107
+ 'security': '<?php echo wp_create_nonce( "codection-security" ); ?>',
108
+ };
109
+
110
+ $.post( ajaxurl, data, function( response ) {
111
+ console.log( response );
112
+ var response = JSON.parse( response );
113
+ $( '#title' ).val( response.title );
114
+ tinyMCE.get( 'body_mail' ).setContent( response.content );
115
+ $( '#template_id' ).val( response.id );
116
+ $( '#save_mail_template_options' ).click();
117
+ });
118
+ } );
119
+ } );
120
+ </script>
121
+ <?php
122
+ }
123
+ }
classes/email-templates.php ADDED
@@ -0,0 +1,161 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) exit;
4
+
5
+ class ACUI_Email_Template{
6
+ function __construct(){
7
+ add_action( 'init', array( $this, 'cpt_email_template' ), 0 );
8
+ add_action( 'edit_form_after_editor', array( $this, 'email_templates_edit_form_after_editor' ), 10, 1 );
9
+ add_action( 'wp_ajax_acui_refresh_enable_email_templates', array( $this, 'refresh_enable_email_templates' ) );
10
+ add_action( 'wp_ajax_acui_email_template_selected', array( $this, 'email_template_selected' ) );
11
+ add_action( 'add_meta_boxes', array( $this, 'add_meta_boxes' ) );
12
+ add_action( 'admin_enqueue_scripts', array( $this, 'load_admin_scripts' ), 10, 1 );
13
+ add_action( 'save_post', array( $this, 'save_post' ) );
14
+ }
15
+
16
+ function cpt_email_template() {
17
+ if( !get_option( 'acui_enable_email_templates' ) )
18
+ return;
19
+
20
+ $labels = array(
21
+ 'name' => _x( 'Email templates (Import Users From CSV With Meta)', 'Post Type General Name', 'import-users-from-csv-with-meta' ),
22
+ 'singular_name' => _x( 'Email template (Import Users From CSV With Meta)', 'Post Type Singular Name', 'import-users-from-csv-with-meta' ),
23
+ 'menu_name' => __( 'Email templates (Import Users)', 'import-users-from-csv-with-meta' ),
24
+ 'name_admin_bar' => __( 'Email templates (Import Users From CSV With Meta)', 'import-users-from-csv-with-meta' ),
25
+ 'archives' => __( 'Item Archives', 'import-users-from-csv-with-meta' ),
26
+ 'attributes' => __( 'Item Attributes', 'import-users-from-csv-with-meta' ),
27
+ 'parent_item_colon' => __( 'Parent Item:', 'import-users-from-csv-with-meta' ),
28
+ 'all_items' => __( 'All email template', 'import-users-from-csv-with-meta' ),
29
+ 'add_new_item' => __( 'Add new email template', 'import-users-from-csv-with-meta' ),
30
+ 'add_new' => __( 'Add new email template', 'import-users-from-csv-with-meta' ),
31
+ 'new_item' => __( 'New email template', 'import-users-from-csv-with-meta' ),
32
+ 'edit_item' => __( 'Edit email template', 'import-users-from-csv-with-meta' ),
33
+ 'update_item' => __( 'Update email template', 'import-users-from-csv-with-meta' ),
34
+ 'view_item' => __( 'View email template', 'import-users-from-csv-with-meta' ),
35
+ 'view_items' => __( 'View email templates', 'import-users-from-csv-with-meta' ),
36
+ 'search_items' => __( 'Search email template', 'import-users-from-csv-with-meta' ),
37
+ 'not_found' => __( 'Not found', 'import-users-from-csv-with-meta' ),
38
+ 'not_found_in_trash' => __( 'Not found in Trash', 'import-users-from-csv-with-meta' ),
39
+ 'featured_image' => __( 'Featured Image', 'import-users-from-csv-with-meta' ),
40
+ 'set_featured_image' => __( 'Set featured image', 'import-users-from-csv-with-meta' ),
41
+ 'remove_featured_image' => __( 'Remove featured image', 'import-users-from-csv-with-meta' ),
42
+ 'use_featured_image' => __( 'Use as featured image', 'import-users-from-csv-with-meta' ),
43
+ 'insert_into_item' => __( 'Insert into email template', 'import-users-from-csv-with-meta' ),
44
+ 'uploaded_to_this_item' => __( 'Uploaded to this email template', 'import-users-from-csv-with-meta' ),
45
+ 'items_list' => __( 'Items list', 'import-users-from-csv-with-meta' ),
46
+ 'items_list_navigation' => __( 'Email template list navigation', 'import-users-from-csv-with-meta' ),
47
+ 'filter_items_list' => __( 'Filter email template list', 'import-users-from-csv-with-meta' ),
48
+ );
49
+ $args = array(
50
+ 'label' => __( 'Mail template (Import Users From CSV With Meta)', 'import-users-from-csv-with-meta' ),
51
+ 'description' => __( 'Mail templates for Import Users From CSV With Meta', 'import-users-from-csv-with-meta' ),
52
+ 'labels' => $labels,
53
+ 'supports' => array( 'title', 'editor' ),
54
+ 'hierarchical' => true,
55
+ 'public' => false,
56
+ 'show_ui' => true,
57
+ 'show_in_menu' => true,
58
+ 'menu_position' => 100,
59
+ 'menu_icon' => 'dashicons-email',
60
+ 'show_in_admin_bar' => true,
61
+ 'show_in_nav_menus' => false,
62
+ 'can_export' => true,
63
+ 'has_archive' => false,
64
+ 'exclude_from_search' => true,
65
+ 'publicly_queryable' => false,
66
+ 'rewrite' => false,
67
+ 'capability_type' => 'page',
68
+ );
69
+ register_post_type( 'acui_email_template', $args );
70
+
71
+ }
72
+
73
+ public static function email_templates_edit_form_after_editor( $post = "" ){
74
+ if( !empty( $post ) && $post->post_type != 'acui_email_template' )
75
+ return;
76
+ ?>
77
+ <p><?php _e( 'You can use', 'import-users-from-csv-with-meta' ); ?></p>
78
+ <ul style="list-style-type:disc; margin-left:2em;">
79
+ <li>**username** = <?php _e( 'username to login', 'import-users-from-csv-with-meta' ); ?></li>
80
+ <li>**password** = <?php _e( 'user password', 'import-users-from-csv-with-meta' ); ?></li>
81
+ <li>**loginurl** = <?php _e( 'current site login url', 'import-users-from-csv-with-meta' ); ?></li>
82
+ <li>**lostpasswordurl** = <?php _e( 'lost password url', 'import-users-from-csv-with-meta' ); ?></li>
83
+ <li>**passwordreseturl** = <?php _e( 'password reset url', 'import-users-from-csv-with-meta' ); ?></li>
84
+ <li>**email** = <?php _e( 'user email', 'import-users-from-csv-with-meta' ); ?></li>
85
+ <li><?php _e( "You can also use any WordPress user standard field or an own metadata, if you have used it in your CSV. For example, if you have a first_name column, you could use **first_name** or any other meta_data like **my_custom_meta**", 'import-users-from-csv-with-meta' ) ;?></li>
86
+ </ul>
87
+ <?php
88
+ }
89
+
90
+ function refresh_enable_email_templates(){
91
+ check_ajax_referer( 'codection-security', 'security' );
92
+ update_option( 'acui_enable_email_templates', ( $_POST[ 'enable' ] == "true" ) );
93
+ die();
94
+ }
95
+
96
+ function email_template_selected(){
97
+ check_ajax_referer( 'codection-security', 'security' );
98
+ $email_template = get_post( intval( $_POST['email_template_selected'] ) );
99
+
100
+ echo json_encode( array( 'id' => $email_template->ID, 'title' => $email_template->post_title, 'content' => wpautop( $email_template->post_content ) ) );
101
+ die();
102
+ }
103
+
104
+ function add_meta_boxes(){
105
+ add_meta_box( 'email_template_attachments',
106
+ __( 'Attachment', 'import-users-from-csv-with-meta' ),
107
+ array( $this, 'email_template_attachments' ),
108
+ 'acui_email_template',
109
+ 'side',
110
+ 'core' );
111
+ }
112
+
113
+ function load_admin_scripts( $hook ) {
114
+ global $typenow, $acui_url_plugin;
115
+
116
+ if( $typenow == 'acui_email_template' || $hook == 'tools_page_acui' ) {
117
+ wp_enqueue_media();
118
+ wp_register_script( 'meta-box-image', $acui_url_plugin . '/assets/email-template-attachment-admin.js', array( 'jquery' ) );
119
+ wp_localize_script( 'meta-box-image', 'meta_image',
120
+ array(
121
+ 'title' => __( 'Choose or upload file', 'import-users-from-csv-with-meta' ),
122
+ 'button' => __( 'Use this file', 'import-users-from-csv-with-meta' ),
123
+ )
124
+ );
125
+ wp_enqueue_script( 'meta-box-image' );
126
+ }
127
+ }
128
+
129
+ public function email_template_attachments( $post ){
130
+ $email_template_attachment_id = get_post_meta( $post->ID, 'email_template_attachment_id', true );
131
+ ?>
132
+ <fieldset>
133
+ <div>
134
+ <label for="email_template_attachment_file"><?php _e( 'Attachment', 'import-users-from-csv-with-meta' )?></label><br>
135
+ <input type="url" class="large-text" name="email_template_attachment_file" id="email_template_attachment_file" value="<?php echo wp_get_attachment_url( $email_template_attachment_id ); ?>" readonly/><br>
136
+ <input type="hidden" name="email_template_attachment_id" id="email_template_attachment_id" value="<?php echo $email_template_attachment_id ?>"/>
137
+ <button type="button" class="button" id="acui_email_template_upload_button"><?php _e( 'Upload file', 'import-users-from-csv-with-meta' )?></button>
138
+ </div>
139
+ </fieldset>
140
+ <?php
141
+ wp_nonce_field( 'acui_email_template_attachment', 'acui_email_template_attachment' );
142
+ }
143
+
144
+ function save_post( $post_id ){
145
+ if( !wp_verify_nonce( $_POST['acui_email_template_attachment'], 'acui_email_template_attachment' ) ) {
146
+ return $post_id;
147
+ }
148
+
149
+ if( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
150
+ return $post_id;
151
+ }
152
+
153
+ if( 'acui_email_template' != $_POST['post_type'] ) {
154
+ return $post_id;
155
+ }
156
+
157
+ update_post_meta( $post_id, 'email_template_attachment_id', intval( $_POST['email_template_attachment_id'] ) );
158
+ }
159
+ }
160
+
161
+ new ACUI_Email_Template();
classes/frontend.php ADDED
@@ -0,0 +1,98 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) exit;
4
+
5
+ class ACUI_Frontend{
6
+ function admin_gui(){
7
+ $send_mail_frontend = get_option( "acui_frontend_send_mail");
8
+ $send_mail_updated_frontend = get_option( "acui_frontend_send_mail_updated");
9
+ $role = get_option( "acui_frontend_role");
10
+ $activate_users_wp_members = get_option( "acui_frontend_activate_users_wp_members");
11
+
12
+ if( empty( $send_mail_frontend ) )
13
+ $send_mail_frontend = false;
14
+
15
+ if( empty( $send_mail_updated_frontend ) )
16
+ $send_mail_updated_frontend = false;
17
+ ?>
18
+ <h3><?php _e( "Execute an import of users in the frontend", 'import-users-from-csv-with-meta' ); ?></h3>
19
+
20
+ <form method="POST" enctype="multipart/form-data" action="" accept-charset="utf-8">
21
+ <table class="form-table">
22
+ <tbody>
23
+ <tr class="form-field">
24
+ <th scope="row"><label for=""><?php _e( 'Use this shortcode in any page or post', 'import-users-from-csv-with-meta' ); ?></label></th>
25
+ <td>
26
+ <pre>[import-users-from-csv-with-meta]</pre>
27
+ <input class="button-primary" type="button" id="copy_to_clipboard" value="<?php _e( 'Copy to clipboard', 'import-users-from-csv-with-meta'); ?>"/>
28
+ </td>
29
+ </tr>
30
+ <tr class="form-field form-required">
31
+ <th scope="row"><label for="send-mail-frontend"><?php _e( 'Send mail when using frontend import?', 'import-users-from-csv-with-meta' ); ?></label></th>
32
+ <td>
33
+ <input type="checkbox" name="send-mail-frontend" value="yes" <?php if( $send_mail_frontend == true ) echo "checked='checked'"; ?>/>
34
+ </td>
35
+ </tr>
36
+ <tr class="form-field form-required">
37
+ <th scope="row"><label for="send-mail-updated-frontend"><?php _e( 'Send mail also to users that are being updated?', 'import-users-from-csv-with-meta' ); ?></label></th>
38
+ <td>
39
+ <input type="checkbox" name="send-mail-updated-frontend" value="yes" <?php if( $send_mail_updated_frontend == true ) echo "checked='checked'"; ?>/>
40
+ </td>
41
+ </tr>
42
+ <tr class="form-field form-required">
43
+ <th scope="row"><label for="role"><?php _e( 'Role', 'import-users-from-csv-with-meta' ); ?></label></th>
44
+ <td>
45
+ <select id="role-frontend" name="role-frontend">
46
+ <?php
47
+ if( $role == '' )
48
+ echo "<option selected='selected' value=''>" . __( 'Disable role assignement in frontend import', 'import-users-from-csv-with-meta' ) . "</option>";
49
+ else
50
+ echo "<option value=''>" . __( 'Disable role assignement in frontend import', 'import-users-from-csv-with-meta' ) . "</option>";
51
+
52
+ $list_roles = acui_get_editable_roles();
53
+ foreach ($list_roles as $key => $value) {
54
+ if($key == $role)
55
+ echo "<option selected='selected' value='$key'>$value</option>";
56
+ else
57
+ echo "<option value='$key'>$value</option>";
58
+ }
59
+ ?>
60
+ </select>
61
+ <p class="description"><?php _e( 'Which role would be used to import users?', 'import-users-from-csv-with-meta' ); ?></p>
62
+ </td>
63
+ </tr>
64
+
65
+ <?php if( is_plugin_active( 'wp-members/wp-members.php' ) ): ?>
66
+
67
+ <tr class="form-field form-required">
68
+ <th scope="row"><label>Activate user when they are being imported?</label></th>
69
+ <td>
70
+ <select name="activate_users_wp_members">
71
+ <option value="no_activate" <?php selected( $activate_users_wp_members,'no_activate', true ); ?>><?php _e( 'Do not activate users', 'import-users-from-csv-with-meta' ); ?></option>
72
+ <option value="activate" <?php selected( $activate_users_wp_members,'activate', true ); ?>><?php _e( 'Activate users when they are being imported', 'import-users-from-csv-with-meta' ); ?></option>
73
+ </select>
74
+
75
+ <p class="description"><strong>(<?php _e( 'Only for', 'import-users-from-csv-with-meta' ); ?> <a href="https://wordpress.org/plugins/wp-members/"><?php _e( 'WP Members', 'import-users-from-csv-with-meta' ); ?></a> <?php _e( 'users', 'import-users-from-csv-with-meta' ); ?>)</strong>.</p>
76
+ </td>
77
+ </tr>
78
+
79
+ <?php endif; ?>
80
+ </tbody>
81
+ </table>
82
+ <input class="button-primary" type="submit" value="<?php _e( 'Save frontend import options', 'import-users-from-csv-with-meta'); ?>"/>
83
+ </form>
84
+
85
+ <script>
86
+ jQuery( document ).ready( function( $ ){
87
+ $( '#copy_to_clipboard' ).click( function(){
88
+ var $temp = $("<input>");
89
+ $("body").append($temp);
90
+ $temp.val( '[import-users-from-csv-with-meta]' ).select();
91
+ document.execCommand("copy");
92
+ $temp.remove();
93
+ } );
94
+ });
95
+ </script>
96
+ <?php
97
+ }
98
+ }
classes/help.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) exit;
4
+
5
+ class ACUI_Help{
6
+ public static function message(){
7
+ ?>
8
+ <div class="postbox">
9
+ <h3 class="hndle"><span>&nbsp;<?php _e( 'Need help with WordPress or WooCommerce?', 'import-users-from-csv-with-meta' ); ?></span></h3>
10
+
11
+ <div class="inside" style="display: block;">
12
+ <p><?php _e( 'Hi! we are', 'import-users-from-csv-with-meta' ); ?> <a href="https://twitter.com/fjcarazo" target="_blank" title="Javier Carazo">Javier Carazo</a> <?php _e( 'and the team of', 'import-users-from-csv-with-meta' ) ?> <a href="http://codection.com">Codection</a>, <?php _e( 'developers of this plugin.', 'import-users-from-csv-with-meta' ); ?></p>
13
+ <p><?php _e( 'We work everyday with WordPress and WooCommerce, if you need help hire us, send us a message to', 'import-users-from-csv-with-meta' ); ?> <a href="mailto:contacto@codection.com">contacto@codection.com</a>.</p>
14
+ <div style="clear:both;"></div>
15
+ </div>
16
+ </div>
17
+ <?php
18
+ }
19
+ }
classes/homepage.php ADDED
@@ -0,0 +1,364 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) exit;
4
+
5
+ class ACUI_Homepage{
6
+ public static function admin_gui(){
7
+ $args_old_csv = array( 'post_type'=> 'attachment', 'post_mime_type' => 'text/csv', 'post_status' => 'inherit', 'posts_per_page' => -1 );
8
+ $old_csv_files = new WP_Query( $args_old_csv );
9
+
10
+ acui_check_options();
11
+ ?>
12
+ <div class="wrap acui">
13
+
14
+ <?php if( $old_csv_files->found_posts > 0 ): ?>
15
+ <div class="postbox">
16
+ <div title="<?php _e( 'Click to open/close', 'import-users-from-csv-with-meta' ); ?>" class="handlediv">
17
+ <br>
18
+ </div>
19
+
20
+ <h3 class="hndle"><span>&nbsp;&nbsp;&nbsp;<?php _e( 'Old CSV files uploaded', 'import-users-from-csv-with-meta' ); ?></span></h3>
21
+
22
+ <div class="inside" style="display: block;">
23
+ <p><?php _e( 'For security reasons you should delete this files, probably they would be visible in the Internet if a bot or someone discover the URL. You can delete each file or maybe you want delete all CSV files you have uploaded:', 'import-users-from-csv-with-meta' ); ?></p>
24
+ <input type="button" value="<?php _e( 'Delete all CSV files uploaded', 'import-users-from-csv-with-meta' ); ?>" id="bulk_delete_attachment" style="float:right;" />
25
+ <ul>
26
+ <?php while($old_csv_files->have_posts()) :
27
+ $old_csv_files->the_post();
28
+
29
+ if( get_the_date() == "" )
30
+ $date = "undefined";
31
+ else
32
+ $date = get_the_date();
33
+ ?>
34
+ <li><a href="<?php echo wp_get_attachment_url( get_the_ID() ); ?>"><?php the_title(); ?></a> <?php _e( 'uploaded on', 'import-users-from-csv-with-meta' ) . ' ' . $date; ?> <input type="button" value="<?php _e( 'Delete', 'import-users-from-csv-with-meta' ); ?>" class="delete_attachment" attach_id="<?php the_ID(); ?>" /></li>
35
+ <?php endwhile; ?>
36
+ <?php wp_reset_postdata(); ?>
37
+ </ul>
38
+ <div style="clear:both;"></div>
39
+ </div>
40
+ </div>
41
+ <?php endif; ?>
42
+
43
+ <div id='message' class='updated'><?php _e( 'File must contain at least <strong>2 columns: username and email</strong>. These should be the first two columns and it should be placed <strong>in this order: username and email</strong>. If there are more columns, this plugin will manage it automatically.', 'import-users-from-csv-with-meta' ); ?></div>
44
+ <div id='message-password' class='error'><?php _e( 'Please, read carefully how <strong>passwords are managed</strong> and also take note about capitalization, this plugin is <strong>case sensitive</strong>.', 'import-users-from-csv-with-meta' ); ?></div>
45
+
46
+ <div>
47
+ <h2><?php _e( 'Import users from CSV','import-users-from-csv-with-meta' ); ?></h2>
48
+ </div>
49
+
50
+ <div style="clear:both;"></div>
51
+
52
+ <div class="main_bar">
53
+ <form method="POST" enctype="multipart/form-data" action="" accept-charset="utf-8" onsubmit="return check();">
54
+ <table class="form-table">
55
+ <tbody>
56
+ <tr class="form-field form-required">
57
+ <th scope="row"><label><?php _e( 'Update existing users?', 'import-users-from-csv-with-meta' ); ?></label></th>
58
+ <td>
59
+ <select name="update_existing_users">
60
+ <option value="yes"><?php _e( 'Yes', 'import-users-from-csv-with-meta' ); ?></option>
61
+ <option value="no"><?php _e( 'No', 'import-users-from-csv-with-meta' ); ?></option>
62
+ </select>
63
+ </td>
64
+ </tr>
65
+
66
+ <tr class="form-field">
67
+ <th scope="row"><label for="role"><?php _e( 'Default role', 'import-users-from-csv-with-meta' ); ?></label></th>
68
+ <td>
69
+ <?php
70
+ $list_roles = acui_get_editable_roles();
71
+
72
+ foreach ($list_roles as $key => $value) {
73
+ if($key == "subscriber")
74
+ echo "<label style='margin-right:5px;'><input name='role[]' type='checkbox' checked='checked' value='$key'/>$value</label>";
75
+ else
76
+ echo "<label style='margin-right:5px;'><input name='role[]' type='checkbox' value='$key'/>$value</label>";
77
+ }
78
+ ?>
79
+
80
+ <p class="description"><?php _e( 'You can also import roles from a CSV column. Please read documentation tab to see how it can be done. If you choose more than one role, the roles would be assigned correctly but you should use some plugin like <a href="https://wordpress.org/plugins/user-role-editor/">User Role Editor</a> to manage them.', 'import-users-from-csv-with-meta' ); ?></p>
81
+ </td>
82
+ </tr>
83
+
84
+ <tr class="form-field form-required">
85
+ <th scope="row"><label><?php _e( 'Update roles for existing users?', 'import-users-from-csv-with-meta' ); ?></label></th>
86
+ <td>
87
+ <select name="update_roles_existing_users">
88
+ <option value="no"><?php _e( 'No', 'import-users-from-csv-with-meta' ); ?></option>
89
+ <option value="yes"><?php _e( 'Yes, update and override existing roles', 'import-users-from-csv-with-meta' ); ?></option>
90
+ <option value="yes_no_override"><?php _e( 'Yes, add new roles and not override existing ones', 'import-users-from-csv-with-meta' ); ?></option>
91
+ </select>
92
+ </td>
93
+ </tr>
94
+
95
+ <tr class="form-field form-required">
96
+ <th scope="row"><label><?php _e( 'CSV file <span class="description">(required)</span></label>', 'import-users-from-csv-with-meta' ); ?></th>
97
+ <td>
98
+ <div id="upload_file">
99
+ <input type="file" name="uploadfiles[]" id="uploadfiles" size="35" class="uploadfiles" />
100
+ <?php _e( '<em>or you can choose directly a file from your host,', 'import-users-from-csv-with-meta' ) ?> <a href="#" class="toggle_upload_path"><?php _e( 'click here', 'import-users-from-csv-with-meta' ) ?></a>.</em>
101
+ </div>
102
+ <div id="introduce_path" style="display:none;">
103
+ <input placeholder="<?php _e( 'You have to introduce the path to file, i.e.:' ,'import-users-from-csv-with-meta' ); ?><?php $upload_dir = wp_upload_dir(); echo $upload_dir["path"]; ?>/test.csv" type="text" name="path_to_file" id="path_to_file" value="<?php echo dirname( __FILE__ ); ?>/test.csv" style="width:70%;" />
104
+ <em><?php _e( 'or you can upload it directly from your PC', 'import-users-from-csv-with-meta' ); ?>, <a href="#" class="toggle_upload_path"><?php _e( 'click here', 'import-users-from-csv-with-meta' ); ?></a>.</em>
105
+ </div>
106
+ </td>
107
+ </tr>
108
+
109
+ <tr class="form-field form-required">
110
+ <th scope="row"><label><?php _e( 'What should the plugin do with empty cells?', 'import-users-from-csv-with-meta' ); ?></label></th>
111
+ <td>
112
+ <select name="empty_cell_action">
113
+ <option value="leave"><?php _e( 'Leave the old value for this metadata', 'import-users-from-csv-with-meta' ); ?></option>
114
+ <option value="delete"><?php _e( 'Delete the metadata', 'import-users-from-csv-with-meta' ); ?></option>
115
+ </select>
116
+ </td>
117
+ </tr>
118
+
119
+ <?php if( is_plugin_active( 'buddypress/bp-loader.php' ) ):
120
+
121
+ if( !class_exists( "BP_XProfile_Group" ) ){
122
+ require_once( WP_PLUGIN_DIR . "/buddypress/bp-xprofile/classes/class-bp-xprofile-group.php" );
123
+ }
124
+
125
+ $buddypress_fields = array();
126
+ $buddypress_types=array();
127
+ $profile_groups = BP_XProfile_Group::get( array( 'fetch_fields' => true ) );
128
+
129
+ if ( !empty( $profile_groups ) ) {
130
+ foreach ( $profile_groups as $profile_group ) {
131
+ if ( !empty( $profile_group->fields ) ) {
132
+ foreach ( $profile_group->fields as $field ) {
133
+ $buddypress_fields[] = $field->name;
134
+ $buddypress_types[] = $field->type;
135
+ }
136
+ }
137
+ }
138
+ }
139
+ ?>
140
+
141
+ <tr class="form-field form-required">
142
+ <th scope="row"><label><?php _e( 'BuddyPress users', 'import-users-from-csv-with-meta' ); ?></label></th>
143
+ <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' ); ?>
144
+ <ul style="list-style:disc outside none;margin-left:2em;">
145
+ <?php foreach ($buddypress_fields as $buddypress_field ): ?><li><?php echo $buddypress_field; ?></li><?php endforeach; ?>
146
+ </ul>
147
+ <?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' ); ?>
148
+
149
+ <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>
150
+ </td>
151
+ </tr>
152
+
153
+ <?php endif; ?>
154
+
155
+ <?php if( is_plugin_active( 'wp-members/wp-members.php' ) ): ?>
156
+
157
+ <tr class="form-field form-required">
158
+ <th scope="row"><label>Activate user when they are being imported?</label></th>
159
+ <td>
160
+ <select name="activate_users_wp_members">
161
+ <option value="no_activate"><?php _e( 'Do not activate users', 'import-users-from-csv-with-meta' ); ?></option>
162
+ <option value="activate"><?php _e( 'Activate users when they are being imported', 'import-users-from-csv-with-meta' ); ?></option>
163
+ </select>
164
+
165
+ <p class="description"><strong>(<?php _e( 'Only for', 'import-users-from-csv-with-meta' ); ?> <a href="https://wordpress.org/plugins/wp-members/"><?php _e( 'WP Members', 'import-users-from-csv-with-meta' ); ?></a> <?php _e( 'users', 'import-users-from-csv-with-meta' ); ?>)</strong>.</p>
166
+ </td>
167
+
168
+ </tr>
169
+
170
+ <?php endif; ?>
171
+
172
+ <?php if( is_plugin_active( 'new-user-approve/new-user-approve.php' ) ): ?>
173
+
174
+ <tr class="form-field form-required">
175
+ <th scope="row"><label><?php _e( 'Approve users at the same time is being created', 'import-users-from-csv-with-meta' ); ?></label></th>
176
+ <td>
177
+ <select name="approve_users_new_user_appove">
178
+ <option value="no_approve"><?php _e( 'Do not approve users', 'import-users-from-csv-with-meta' ); ?></option>
179
+ <option value="approve"><?php _e( 'Approve users when they are being imported', 'import-users-from-csv-with-meta' ); ?></option>
180
+ </select>
181
+
182
+ <p class="description"><strong>(<?php _e( 'Only for', 'import-users-from-csv-with-meta' ); ?> <a href="https://es.wordpress.org/plugins/new-user-approve/"><?php _e( 'New User Approve', 'import-users-from-csv-with-meta' ); ?></a> <?php _e( 'users', 'import-users-from-csv-with-meta' ); ?></strong>.</p>
183
+ </td>
184
+
185
+ </tr>
186
+
187
+ <?php endif; ?>
188
+
189
+ <?php if( is_plugin_active( 'allow-multiple-accounts/allow-multiple-accounts.php' ) ): ?>
190
+
191
+ <tr class="form-field form-required">
192
+ <th scope="row"><label><?php _e( 'Repeated email in different users?', 'import-users-from-csv-with-meta' ); ?></label></th>
193
+ <td>
194
+ <select name="allow_multiple_accounts">
195
+ <option value="not_allowed"><?php _e( 'Not allowed', 'import-users-from-csv-with-meta' ); ?></option>
196
+ <option value="allowed"><?php _e( 'Allowed', 'import-users-from-csv-with-meta' ); ?></option>
197
+ </select>
198
+ <p class="description"><strong>(<?php _e( 'Only for', 'import-users-from-csv-with-meta' ); ?> <a href="https://wordpress.org/plugins/allow-multiple-accounts/"><?php _e( 'Allow Multiple Accounts', 'import-users-from-csv-with-meta' ); ?></a> <?php _e( 'users', 'import-users-from-csv-with-meta'); ?>)</strong>. <?php _e('Allow multiple user accounts to be created having the same email address.','import-users-from-csv-with-meta' ); ?></p>
199
+ </td>
200
+ </tr>
201
+
202
+ <?php endif; ?>
203
+
204
+ <?php if( is_plugin_active( 'wp-access-areas/wp-access-areas.php' ) ): ?>
205
+
206
+ <tr class="form-field form-required">
207
+ <th scope="row"><label><?php _e('WordPress Access Areas is activated','import-users-from-csv-with-meta'); ?></label></th>
208
+ <td>
209
+ <p class="description"><?php _e('As user of','import-users-from-csv-with-meta' ); ?> <a href="https://wordpress.org/plugins/wp-access-areas/"><?php _e( 'WordPress Access Areas', 'import-users-from-csv-with-meta' )?></a> <?php _e( 'you can use the Access Areas created', 'import-users-from-csv-with-meta' ); ?> <a href="<?php echo admin_url( 'users.php?page=user_labels' ); ?>"><?php _e( 'here', 'import-users-from-csv-with-meta' ); ?></a> <?php _e( 'and use this areas in your own CSV file. Please use the column name <strong>wp-access-areas</strong> and in each row use <strong>the name that you have used', 'import-users-from-csv-with-meta' ); ?> <a href="<?php echo admin_url( 'users.php?page=user_labels' ); ?>"><?php _e( 'here', 'import-users-from-csv-with-meta' ); ?></a></strong><?php _e( ', like this ones:', 'import-users-from-csv-with-meta' ); ?></p>
210
+ <ol>
211
+ <?php
212
+ $data = WPAA_AccessArea::get_available_userlabels( '0,5' , NULL );
213
+ foreach ( $data as $access_area_object ): ?>
214
+ <li><?php echo $access_area_object->cap_title; ?></li>
215
+ <?php endforeach; ?>
216
+
217
+ </ol>
218
+ <p class="description"><?php _e( "If you leave this cell empty for some user or the access area indicated doesn't exist, user won't be assigned to any access area. You can choose more than one area for each user using pads between them in the same row, i.e.: ", 'import-users-from-csv-with-meta' ) ?>access_area1#accces_area2</p>
219
+ </td>
220
+ </tr>
221
+
222
+ <?php endif; ?>
223
+
224
+ <tr class="form-field">
225
+ <th scope="row"><label for="user_login"><?php _e( 'Send mail', 'import-users-from-csv-with-meta' ); ?></label></th>
226
+ <td>
227
+ <p>
228
+ <?php _e( 'Do you wish to send a mail with credentials and other data?', 'import-users-from-csv-with-meta' ); ?>
229
+ <input type="checkbox" name="sends_email" value="yes" <?php if( get_option( 'acui_manually_send_mail' ) ): ?> checked="checked" <?php endif; ?>>
230
+ </p>
231
+ <p>
232
+ <?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' ); ?>
233
+ <input type="checkbox" name="send_email_updated" value="yes" <?php if( get_option( 'acui_manually_send_mail_updated' ) ): ?> checked="checked" <?php endif; ?>>
234
+ </p>
235
+ </td>
236
+ </tr>
237
+ </tbody>
238
+ </table>
239
+
240
+ <?php wp_nonce_field( 'acui-import', 'acui-nonce' ); ?>
241
+
242
+ <input class="button-primary" type="submit" name="uploadfile" id="uploadfile_btn" value="<?php _e( 'Start importing', 'import-users-from-csv-with-meta' ); ?>"/>
243
+ </form>
244
+ </div>
245
+
246
+ <div class="sidebar">
247
+ <div class="sidebar_section become_patreon">
248
+ <a class="patreon" color="primary" type="button" name="become-a-patron" data-tag="become-patron-button" href="https://www.patreon.com/bePatron?c=1741454" role="button">
249
+ <div><span><?php _e( 'Become a patron', 'import-users-from-csv-with-meta'); ?></span></div>
250
+ </a>
251
+ </div>
252
+
253
+ <?php if( substr( get_locale(), 0, 2 ) == 'es' ): ?>
254
+ <div class="sidebar_section" id="webempresa">
255
+ <h3>Tu web más rápida con Webempresa</h3>
256
+ <ul>
257
+ <li><label>Además ahora un <a href="https://codection.com/25-de-descuento-en-el-mejor-hosting-en-espanol-con-webempresa/">25% de descuento</a>.</label></li>
258
+ </ul>
259
+ <a href="https://codection.com/25-de-descuento-en-el-mejor-hosting-en-espanol-con-webempresa/" target="_blank">
260
+ <img src="<?php echo plugin_dir_url( __FILE__ ); ?>assets/webempresa_logo.png">
261
+ </a>
262
+ </div>
263
+ <?php else: ?>
264
+ <div class="sidebar_section" style="padding:0 !important;border:none !important;background:none !important;">
265
+ <a href="https://codection.com/how-to-transfer-your-website-to-inmotion-hosting/" target="_blank">
266
+ <img src="<?php echo plugin_dir_url( __FILE__ ); ?>assets/codection-inmotion.png">
267
+ </a>
268
+ </div>
269
+ <?php endif; ?>
270
+
271
+ <div class="sidebar_section" id="vote_us">
272
+ <h3>Rate Us</h3>
273
+ <ul>
274
+ <li><label>If you like it, Please vote and support us.</label></li>
275
+ </ul>
276
+ </div>
277
+ <div class="sidebar_section">
278
+ <h3>Having Issues?</h3>
279
+ <ul>
280
+ <li><label>You can create a ticket</label> <a target="_blank" href="http://wordpress.org/support/plugin/import-users-from-csv-with-meta"><label>WordPress support forum</label></a></li>
281
+ <li><label>You can ask for premium support</label> <a target="_blank" href="mailto:contacto@codection.com"><label>contacto@codection.com</label></a></li>
282
+ </ul>
283
+ </div>
284
+ <div class="sidebar_section">
285
+ <h3>Donate</h3>
286
+ <ul>
287
+ <li><label>If you appreciate our work and you want to help us to continue developing it and giving the best support</label> <a target="_blank" href="https://paypal.me/imalrod"><label>donate</label></a></li>
288
+ </ul>
289
+ </div>
290
+ </div>
291
+
292
+ </div>
293
+ <script type="text/javascript">
294
+ function check(){
295
+ if(document.getElementById("uploadfiles").value == "" && jQuery( "#upload_file" ).is(":visible") ) {
296
+ alert("<?php _e( 'Please choose a file', 'import-users-from-csv-with-meta' ); ?>");
297
+ return false;
298
+ }
299
+
300
+ if( jQuery( "#path_to_file" ).val() == "" && jQuery( "#introduce_path" ).is(":visible") ) {
301
+ alert("<?php _e( 'Please enter a path to the file', 'import-users-from-csv-with-meta' ); ?>");
302
+ return false;
303
+ }
304
+
305
+ if( jQuery("[name=role\\[\\]]input:checkbox:checked").length == 0 ){
306
+ alert("<?php _e( 'Please select a role', 'import-users-from-csv-with-meta'); ?>");
307
+ return false;
308
+ }
309
+ }
310
+
311
+ jQuery( document ).ready( function( $ ){
312
+ $( ".delete_attachment" ).click( function(){
313
+ var answer = confirm( "<?php _e( 'Are you sure to delete this file?', 'import-users-from-csv-with-meta' ); ?>" );
314
+ if( answer ){
315
+ var data = {
316
+ 'action': 'acui_delete_attachment',
317
+ 'attach_id': $( this ).attr( "attach_id" )
318
+ };
319
+
320
+ $.post(ajaxurl, data, function(response) {
321
+ if( response != 1 )
322
+ alert( "<?php _e( 'There were problems deleting the file, please check file permissions', 'import-users-from-csv-with-meta' ); ?>" );
323
+ else{
324
+ alert( "<?php _e( 'File successfully deleted', 'import-users-from-csv-with-meta' ); ?>" );
325
+ document.location.reload();
326
+ }
327
+ });
328
+ }
329
+ });
330
+
331
+ $( "#bulk_delete_attachment" ).click( function(){
332
+ var answer = confirm( "<?php _e( 'Are you sure to delete ALL CSV files uploaded? There can be CSV files from other plugins.', 'import-users-from-csv-with-meta' ); ?>" );
333
+ if( answer ){
334
+ var data = {
335
+ 'action': 'acui_bulk_delete_attachment',
336
+ };
337
+
338
+ $.post(ajaxurl, data, function(response) {
339
+ if( response != 1 )
340
+ alert( "<?php _e( 'There were problems deleting the files, please check files permissions', 'import-users-from-csv-with-meta' ); ?>" );
341
+ else{
342
+ alert( "<?php _e( 'Files successfully deleted', 'import-users-from-csv-with-meta' ); ?>" );
343
+ document.location.reload();
344
+ }
345
+ });
346
+ }
347
+ });
348
+
349
+ $( ".toggle_upload_path" ).click( function( e ){
350
+ e.preventDefault();
351
+
352
+ $("#upload_file,#introduce_path").toggle();
353
+ } );
354
+
355
+ $("#vote_us").click(function(){
356
+ var win=window.open("http://wordpress.org/support/view/plugin-reviews/import-users-from-csv-with-meta?free-counter?rate=5#postform", '_blank');
357
+ win.focus();
358
+ });
359
+
360
+ } );
361
+ </script>
362
+ <?php
363
+ }
364
+ }
email-templates.php CHANGED
@@ -2,94 +2,161 @@
2
 
3
  if ( ! defined( 'ABSPATH' ) ) exit;
4
 
5
- function acui_cpt_email_template() {
6
- if( !get_option( 'acui_enable_email_templates' ) )
7
- return;
 
 
 
 
 
 
 
8
 
9
- $labels = array(
10
- 'name' => _x( 'Email templates (Import Users From CSV With Meta)', 'Post Type General Name', 'import-users-from-csv-with-meta' ),
11
- 'singular_name' => _x( 'Email template (Import Users From CSV With Meta)', 'Post Type Singular Name', 'import-users-from-csv-with-meta' ),
12
- 'menu_name' => __( 'Email templates (Import Users)', 'import-users-from-csv-with-meta' ),
13
- 'name_admin_bar' => __( 'Email templates (Import Users From CSV With Meta)', 'import-users-from-csv-with-meta' ),
14
- 'archives' => __( 'Item Archives', 'import-users-from-csv-with-meta' ),
15
- 'attributes' => __( 'Item Attributes', 'import-users-from-csv-with-meta' ),
16
- 'parent_item_colon' => __( 'Parent Item:', 'import-users-from-csv-with-meta' ),
17
- 'all_items' => __( 'All email template', 'import-users-from-csv-with-meta' ),
18
- 'add_new_item' => __( 'Add new email template', 'import-users-from-csv-with-meta' ),
19
- 'add_new' => __( 'Add new email template', 'import-users-from-csv-with-meta' ),
20
- 'new_item' => __( 'New email template', 'import-users-from-csv-with-meta' ),
21
- 'edit_item' => __( 'Edit email template', 'import-users-from-csv-with-meta' ),
22
- 'update_item' => __( 'Update email template', 'import-users-from-csv-with-meta' ),
23
- 'view_item' => __( 'View email template', 'import-users-from-csv-with-meta' ),
24
- 'view_items' => __( 'View email templates', 'import-users-from-csv-with-meta' ),
25
- 'search_items' => __( 'Search email template', 'import-users-from-csv-with-meta' ),
26
- 'not_found' => __( 'Not found', 'import-users-from-csv-with-meta' ),
27
- 'not_found_in_trash' => __( 'Not found in Trash', 'import-users-from-csv-with-meta' ),
28
- 'featured_image' => __( 'Featured Image', 'import-users-from-csv-with-meta' ),
29
- 'set_featured_image' => __( 'Set featured image', 'import-users-from-csv-with-meta' ),
30
- 'remove_featured_image' => __( 'Remove featured image', 'import-users-from-csv-with-meta' ),
31
- 'use_featured_image' => __( 'Use as featured image', 'import-users-from-csv-with-meta' ),
32
- 'insert_into_item' => __( 'Insert into email template', 'import-users-from-csv-with-meta' ),
33
- 'uploaded_to_this_item' => __( 'Uploaded to this email template', 'import-users-from-csv-with-meta' ),
34
- 'items_list' => __( 'Items list', 'import-users-from-csv-with-meta' ),
35
- 'items_list_navigation' => __( 'Email template list navigation', 'import-users-from-csv-with-meta' ),
36
- 'filter_items_list' => __( 'Filter email template list', 'import-users-from-csv-with-meta' ),
37
- );
38
- $args = array(
39
- 'label' => __( 'Mail template (Import Users From CSV With Meta)', 'import-users-from-csv-with-meta' ),
40
- 'description' => __( 'Mail templates for Import Users From CSV With Meta', 'import-users-from-csv-with-meta' ),
41
- 'labels' => $labels,
42
- 'supports' => array( 'title', 'editor' ),
43
- 'hierarchical' => true,
44
- 'public' => false,
45
- 'show_ui' => true,
46
- 'show_in_menu' => true,
47
- 'menu_position' => 100,
48
- 'menu_icon' => 'dashicons-email',
49
- 'show_in_admin_bar' => true,
50
- 'show_in_nav_menus' => false,
51
- 'can_export' => true,
52
- 'has_archive' => false,
53
- 'exclude_from_search' => true,
54
- 'publicly_queryable' => false,
55
- 'rewrite' => false,
56
- 'capability_type' => 'page',
57
- );
58
- register_post_type( 'acui_email_template', $args );
59
 
60
- }
61
- add_action( 'init', 'acui_cpt_email_template', 0 );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
62
 
63
- function acui_email_templates_edit_form_after_editor( $post = "" ){
64
- if( !empty( $post ) && $post->post_type != 'acui_email_template' )
65
- return;
66
- ?>
67
- <p><?php _e( 'You can use', 'import-users-from-csv-with-meta' ); ?></p>
68
- <ul style="list-style-type:disc; margin-left:2em;">
69
- <li>**username** = <?php _e( 'username to login', 'import-users-from-csv-with-meta' ); ?></li>
70
- <li>**password** = <?php _e( 'user password', 'import-users-from-csv-with-meta' ); ?></li>
71
- <li>**loginurl** = <?php _e( 'current site login url', 'import-users-from-csv-with-meta' ); ?></li>
72
- <li>**lostpasswordurl** = <?php _e( 'lost password url', 'import-users-from-csv-with-meta' ); ?></li>
73
- <li>**passwordreseturl** = <?php _e( 'password reset url', 'import-users-from-csv-with-meta' ); ?></li>
74
- <li>**email** = <?php _e( 'user email', 'import-users-from-csv-with-meta' ); ?></li>
75
- <li><?php _e( "You can also use any WordPress user standard field or an own metadata, if you have used it in your CSV. For example, if you have a first_name column, you could use **first_name** or any other meta_data like **my_custom_meta**", 'import-users-from-csv-with-meta' ) ;?></li>
76
- </ul>
77
- <?php
78
- }
79
- add_action( 'edit_form_after_editor', 'acui_email_templates_edit_form_after_editor', 10, 1 );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
80
 
81
- function acui_refresh_enable_email_templates(){
82
- check_ajax_referer( 'codection-security', 'security' );
83
- update_option( 'acui_enable_email_templates', ( $_POST[ 'enable' ] == "true" ) );
84
- die();
85
- }
86
- add_action( 'wp_ajax_acui_refresh_enable_email_templates', 'acui_refresh_enable_email_templates' );
 
 
87
 
88
- function acui_email_template_selected(){
89
- check_ajax_referer( 'codection-security', 'security' );
90
- $email_template = get_post( intval( $_POST['email_template_selected'] ) );
91
-
92
- echo json_encode( array( 'id' => $email_template->ID, 'title' => $email_template->post_title, 'content' => wpautop( $email_template->post_content ) ) );
93
- die();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
94
  }
95
- add_action( 'wp_ajax_acui_email_template_selected', 'acui_email_template_selected' );
 
2
 
3
  if ( ! defined( 'ABSPATH' ) ) exit;
4
 
5
+ class ACUI_Email_Template{
6
+ function __construct(){
7
+ add_action( 'init', array( $this, 'cpt_email_template' ), 0 );
8
+ add_action( 'edit_form_after_editor', array( $this, 'email_templates_edit_form_after_editor' ), 10, 1 );
9
+ add_action( 'wp_ajax_acui_refresh_enable_email_templates', array( $this, 'refresh_enable_email_templates' ) );
10
+ add_action( 'wp_ajax_acui_email_template_selected', array( $this, 'email_template_selected' ) );
11
+ add_action( 'add_meta_boxes', array( $this, 'add_meta_boxes' ) );
12
+ add_action( 'admin_enqueue_scripts', array( $this, 'load_admin_scripts' ), 10, 1 );
13
+ add_action( 'save_post', array( $this, 'save_post' ) );
14
+ }
15
 
16
+ function cpt_email_template() {
17
+ if( !get_option( 'acui_enable_email_templates' ) )
18
+ return;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
 
20
+ $labels = array(
21
+ 'name' => _x( 'Email templates (Import Users From CSV With Meta)', 'Post Type General Name', 'import-users-from-csv-with-meta' ),
22
+ 'singular_name' => _x( 'Email template (Import Users From CSV With Meta)', 'Post Type Singular Name', 'import-users-from-csv-with-meta' ),
23
+ 'menu_name' => __( 'Email templates (Import Users)', 'import-users-from-csv-with-meta' ),
24
+ 'name_admin_bar' => __( 'Email templates (Import Users From CSV With Meta)', 'import-users-from-csv-with-meta' ),
25
+ 'archives' => __( 'Item Archives', 'import-users-from-csv-with-meta' ),
26
+ 'attributes' => __( 'Item Attributes', 'import-users-from-csv-with-meta' ),
27
+ 'parent_item_colon' => __( 'Parent Item:', 'import-users-from-csv-with-meta' ),
28
+ 'all_items' => __( 'All email template', 'import-users-from-csv-with-meta' ),
29
+ 'add_new_item' => __( 'Add new email template', 'import-users-from-csv-with-meta' ),
30
+ 'add_new' => __( 'Add new email template', 'import-users-from-csv-with-meta' ),
31
+ 'new_item' => __( 'New email template', 'import-users-from-csv-with-meta' ),
32
+ 'edit_item' => __( 'Edit email template', 'import-users-from-csv-with-meta' ),
33
+ 'update_item' => __( 'Update email template', 'import-users-from-csv-with-meta' ),
34
+ 'view_item' => __( 'View email template', 'import-users-from-csv-with-meta' ),
35
+ 'view_items' => __( 'View email templates', 'import-users-from-csv-with-meta' ),
36
+ 'search_items' => __( 'Search email template', 'import-users-from-csv-with-meta' ),
37
+ 'not_found' => __( 'Not found', 'import-users-from-csv-with-meta' ),
38
+ 'not_found_in_trash' => __( 'Not found in Trash', 'import-users-from-csv-with-meta' ),
39
+ 'featured_image' => __( 'Featured Image', 'import-users-from-csv-with-meta' ),
40
+ 'set_featured_image' => __( 'Set featured image', 'import-users-from-csv-with-meta' ),
41
+ 'remove_featured_image' => __( 'Remove featured image', 'import-users-from-csv-with-meta' ),
42
+ 'use_featured_image' => __( 'Use as featured image', 'import-users-from-csv-with-meta' ),
43
+ 'insert_into_item' => __( 'Insert into email template', 'import-users-from-csv-with-meta' ),
44
+ 'uploaded_to_this_item' => __( 'Uploaded to this email template', 'import-users-from-csv-with-meta' ),
45
+ 'items_list' => __( 'Items list', 'import-users-from-csv-with-meta' ),
46
+ 'items_list_navigation' => __( 'Email template list navigation', 'import-users-from-csv-with-meta' ),
47
+ 'filter_items_list' => __( 'Filter email template list', 'import-users-from-csv-with-meta' ),
48
+ );
49
+ $args = array(
50
+ 'label' => __( 'Mail template (Import Users From CSV With Meta)', 'import-users-from-csv-with-meta' ),
51
+ 'description' => __( 'Mail templates for Import Users From CSV With Meta', 'import-users-from-csv-with-meta' ),
52
+ 'labels' => $labels,
53
+ 'supports' => array( 'title', 'editor' ),
54
+ 'hierarchical' => true,
55
+ 'public' => false,
56
+ 'show_ui' => true,
57
+ 'show_in_menu' => true,
58
+ 'menu_position' => 100,
59
+ 'menu_icon' => 'dashicons-email',
60
+ 'show_in_admin_bar' => true,
61
+ 'show_in_nav_menus' => false,
62
+ 'can_export' => true,
63
+ 'has_archive' => false,
64
+ 'exclude_from_search' => true,
65
+ 'publicly_queryable' => false,
66
+ 'rewrite' => false,
67
+ 'capability_type' => 'page',
68
+ );
69
+ register_post_type( 'acui_email_template', $args );
70
 
71
+ }
72
+
73
+ public static function email_templates_edit_form_after_editor( $post = "" ){
74
+ if( !empty( $post ) && $post->post_type != 'acui_email_template' )
75
+ return;
76
+ ?>
77
+ <p><?php _e( 'You can use', 'import-users-from-csv-with-meta' ); ?></p>
78
+ <ul style="list-style-type:disc; margin-left:2em;">
79
+ <li>**username** = <?php _e( 'username to login', 'import-users-from-csv-with-meta' ); ?></li>
80
+ <li>**password** = <?php _e( 'user password', 'import-users-from-csv-with-meta' ); ?></li>
81
+ <li>**loginurl** = <?php _e( 'current site login url', 'import-users-from-csv-with-meta' ); ?></li>
82
+ <li>**lostpasswordurl** = <?php _e( 'lost password url', 'import-users-from-csv-with-meta' ); ?></li>
83
+ <li>**passwordreseturl** = <?php _e( 'password reset url', 'import-users-from-csv-with-meta' ); ?></li>
84
+ <li>**email** = <?php _e( 'user email', 'import-users-from-csv-with-meta' ); ?></li>
85
+ <li><?php _e( "You can also use any WordPress user standard field or an own metadata, if you have used it in your CSV. For example, if you have a first_name column, you could use **first_name** or any other meta_data like **my_custom_meta**", 'import-users-from-csv-with-meta' ) ;?></li>
86
+ </ul>
87
+ <?php
88
+ }
89
+
90
+ function refresh_enable_email_templates(){
91
+ check_ajax_referer( 'codection-security', 'security' );
92
+ update_option( 'acui_enable_email_templates', ( $_POST[ 'enable' ] == "true" ) );
93
+ die();
94
+ }
95
+
96
+ function email_template_selected(){
97
+ check_ajax_referer( 'codection-security', 'security' );
98
+ $email_template = get_post( intval( $_POST['email_template_selected'] ) );
99
+
100
+ echo json_encode( array( 'id' => $email_template->ID, 'title' => $email_template->post_title, 'content' => wpautop( $email_template->post_content ) ) );
101
+ die();
102
+ }
103
 
104
+ function add_meta_boxes(){
105
+ add_meta_box( 'email_template_attachments',
106
+ __( 'Attachment', 'import-users-from-csv-with-meta' ),
107
+ array( $this, 'email_template_attachments' ),
108
+ 'acui_email_template',
109
+ 'side',
110
+ 'core' );
111
+ }
112
 
113
+ function load_admin_scripts( $hook ) {
114
+ global $typenow;
115
+
116
+
117
+ if( $typenow == 'acui_email_template' || $hook == 'tools_page_acui' ) {
118
+ wp_enqueue_media();
119
+ wp_register_script( 'meta-box-image', plugins_url( 'assets/email-template-attachment-admin.js' , __FILE__ ), array( 'jquery' ) );
120
+ wp_localize_script( 'meta-box-image', 'meta_image',
121
+ array(
122
+ 'title' => __( 'Choose or upload file', 'import-users-from-csv-with-meta' ),
123
+ 'button' => __( 'Use this file', 'import-users-from-csv-with-meta' ),
124
+ )
125
+ );
126
+ wp_enqueue_script( 'meta-box-image' );
127
+ }
128
+ }
129
+
130
+ public function email_template_attachments( $post ){
131
+ $email_template_attachment_id = get_post_meta( $post->ID, 'email_template_attachment_id', true );
132
+ ?>
133
+ <fieldset>
134
+ <div>
135
+ <label for="email_template_attachment_file"><?php _e( 'Field Label', 'import-users-from-csv-with-meta' )?></label><br>
136
+ <input type="url" class="large-text" name="email_template_attachment_file" id="email_template_attachment_file" value="<?php echo wp_get_attachment_url( $email_template_attachment_id ); ?>" readonly/><br>
137
+ <input type="hidden" name="email_template_attachment_id" id="email_template_attachment_id" value="<?php echo $email_template_attachment_id ?>"/>
138
+ <button type="button" class="button" id="acui_email_template_upload_button"><?php _e( 'Upload file', 'import-users-from-csv-with-meta' )?></button>
139
+ </div>
140
+ </fieldset>
141
+ <?php
142
+ wp_nonce_field( 'acui_email_template_attachment', 'acui_email_template_attachment' );
143
+ }
144
+
145
+ function save_post( $post_id ){
146
+ if( !wp_verify_nonce( $_POST['acui_email_template_attachment'], 'acui_email_template_attachment' ) ) {
147
+ return $post_id;
148
+ }
149
+
150
+ if( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
151
+ return $post_id;
152
+ }
153
+
154
+ if( 'acui_email_template' != $_POST['post_type'] ) {
155
+ return $post_id;
156
+ }
157
+
158
+ update_post_meta( $post_id, 'email_template_attachment_id', intval( $_POST['email_template_attachment_id'] ) );
159
+ }
160
  }
161
+
162
+ new ACUI_Email_Template();
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.12.1
7
  Author: codection
8
  Author URI: https://codection.com
9
  License: GPL2
@@ -14,7 +14,7 @@ Domain Path: /languages
14
 
15
  if ( ! defined( 'ABSPATH' ) ) exit;
16
 
17
- $url_plugin = WP_PLUGIN_URL . '/' . str_replace( basename( __FILE__ ), "", plugin_basename( __FILE__ ) );
18
  $wp_users_fields = array( "id", "user_nicename", "user_url", "display_name", "nickname", "first_name", "last_name", "description", "jabber", "aim", "yim", "user_registered", "password", "user_pass", "locale" );
19
  $wp_min_fields = array("Username", "Email");
20
  $acui_fields = array( "bp_group", "bp_group_role", "role" );
@@ -24,7 +24,17 @@ include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
24
 
25
  require_once( "smtp.php" );
26
  require_once( "email-repeated.php" );
27
- require_once( "email-templates.php" );
 
 
 
 
 
 
 
 
 
 
28
 
29
  if( is_plugin_active( 'buddypress/bp-loader.php' ) ){
30
  if ( defined( 'BP_VERSION' ) )
@@ -84,6 +94,7 @@ function acui_activate(){
84
  add_option( "acui_mail_subject", __('Welcome to', 'import-users-from-csv-with-meta') . ' ' . get_bloginfo("name"), '', false );
85
  add_option( "acui_mail_body", __('Welcome,', 'import-users-from-csv-with-meta') . '<br/>' . __('Your data to login in this site is:', 'import-users-from-csv-with-meta') . '<br/><ul><li>' . __('URL to login', 'import-users-from-csv-with-meta') . ': **loginurl**</li><li>' . __( 'Username', 'import-users-from-csv-with-meta') . '= **username**</li><li>Password = **password**</li></ul>', '', false );
86
  add_option( "acui_mail_template_id", 0 );
 
87
  add_option( "acui_enable_email_templates", false );
88
 
89
  add_option( "acui_cron_activated", false );
@@ -131,6 +142,7 @@ function acui_delete_options(){
131
  delete_option( "acui_mail_subject" );
132
  delete_option( "acui_mail_body" );
133
  delete_option( "acui_mail_template_id" );
 
134
  delete_option( "acui_enable_email_templates" );
135
 
136
  delete_option( "acui_cron_activated" );
@@ -184,27 +196,22 @@ function acui_plugin_row_meta( $links, $file ){
184
  return $links;
185
  }
186
 
187
- function acui_detect_delimiter($file){
188
- $handle = @fopen($file, "r");
189
- $sumComma = 0;
190
- $sumSemiColon = 0;
191
- $sumBar = 0;
 
 
192
 
193
- if($handle){
194
- while (($data = fgets($handle, 4096)) !== FALSE):
195
- $sumComma += substr_count($data, ",");
196
- $sumSemiColon += substr_count($data, ";");
197
- $sumBar += substr_count($data, "|");
198
- endwhile;
199
  }
200
- fclose($handle);
201
-
202
- if(($sumComma > $sumSemiColon) && ($sumComma > $sumBar))
203
- return ",";
204
- else if(($sumSemiColon > $sumComma) && ($sumSemiColon > $sumBar))
205
- return ";";
206
- else
207
- return "|";
208
  }
209
 
210
  function acui_string_conversion( $string ){
@@ -430,6 +437,7 @@ function acui_save_mail_template( $form_data ){
430
  update_option( "acui_mail_body", stripslashes( $form_data["body_mail"] ) );
431
  update_option( "acui_mail_subject", stripslashes( $form_data["subject_mail"] ) );
432
  update_option( "acui_mail_template_id", stripslashes( $form_data["template_id"] ) );
 
433
 
434
  if( !empty( $form_data["template_id"] ) ){
435
  wp_update_post( array(
@@ -437,6 +445,8 @@ function acui_save_mail_template( $form_data ){
437
  'post_title' => $form_data["subject_mail"],
438
  'post_content' => $form_data["body_mail"],
439
  ) );
 
 
440
  }
441
  ?>
442
  <div class="updated">
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.12.2
7
  Author: codection
8
  Author URI: https://codection.com
9
  License: GPL2
14
 
15
  if ( ! defined( 'ABSPATH' ) ) exit;
16
 
17
+ $acui_url_plugin = WP_PLUGIN_URL . '/' . str_replace( basename( __FILE__ ), "", plugin_basename( __FILE__ ) );
18
  $wp_users_fields = array( "id", "user_nicename", "user_url", "display_name", "nickname", "first_name", "last_name", "description", "jabber", "aim", "yim", "user_registered", "password", "user_pass", "locale" );
19
  $wp_min_fields = array("Username", "Email");
20
  $acui_fields = array( "bp_group", "bp_group_role", "role" );
24
 
25
  require_once( "smtp.php" );
26
  require_once( "email-repeated.php" );
27
+
28
+ require_once( "classes/email-templates.php" );
29
+
30
+ require_once( "classes/homepage.php" );
31
+ require_once( "classes/columns.php" );
32
+ require_once( "classes/frontend.php" );
33
+ require_once( "classes/doc.php" );
34
+ require_once( "classes/email-options.php" );
35
+ require_once( "classes/cron.php" );
36
+ require_once( "classes/donate.php" );
37
+ require_once( "classes/help.php" );
38
 
39
  if( is_plugin_active( 'buddypress/bp-loader.php' ) ){
40
  if ( defined( 'BP_VERSION' ) )
94
  add_option( "acui_mail_subject", __('Welcome to', 'import-users-from-csv-with-meta') . ' ' . get_bloginfo("name"), '', false );
95
  add_option( "acui_mail_body", __('Welcome,', 'import-users-from-csv-with-meta') . '<br/>' . __('Your data to login in this site is:', 'import-users-from-csv-with-meta') . '<br/><ul><li>' . __('URL to login', 'import-users-from-csv-with-meta') . ': **loginurl**</li><li>' . __( 'Username', 'import-users-from-csv-with-meta') . '= **username**</li><li>Password = **password**</li></ul>', '', false );
96
  add_option( "acui_mail_template_id", 0 );
97
+ add_option( "acui_mail_attachment_id", 0 );
98
  add_option( "acui_enable_email_templates", false );
99
 
100
  add_option( "acui_cron_activated", false );
142
  delete_option( "acui_mail_subject" );
143
  delete_option( "acui_mail_body" );
144
  delete_option( "acui_mail_template_id" );
145
+ delete_option( "acui_mail_attachment_id" );
146
  delete_option( "acui_enable_email_templates" );
147
 
148
  delete_option( "acui_cron_activated" );
196
  return $links;
197
  }
198
 
199
+ function acui_detect_delimiter( $file ) {
200
+ $delimiters = array(
201
+ ';' => 0,
202
+ ',' => 0,
203
+ "\t" => 0,
204
+ "|" => 0
205
+ );
206
 
207
+ $handle = @fopen($file, "r");
208
+ $firstLine = fgets($handle);
209
+ fclose($handle);
210
+ foreach ($delimiters as $delimiter => &$count) {
211
+ $count = count(str_getcsv($firstLine, $delimiter));
 
212
  }
213
+
214
+ return array_search(max($delimiters), $delimiters);
 
 
 
 
 
 
215
  }
216
 
217
  function acui_string_conversion( $string ){
437
  update_option( "acui_mail_body", stripslashes( $form_data["body_mail"] ) );
438
  update_option( "acui_mail_subject", stripslashes( $form_data["subject_mail"] ) );
439
  update_option( "acui_mail_template_id", stripslashes( $form_data["template_id"] ) );
440
+ update_option( "acui_mail_attachment_id", stripslashes( $form_data["email_template_attachment_id"] ) );
441
 
442
  if( !empty( $form_data["template_id"] ) ){
443
  wp_update_post( array(
445
  'post_title' => $form_data["subject_mail"],
446
  'post_content' => $form_data["body_mail"],
447
  ) );
448
+
449
+ update_post_meta( $form_data["template_id"], 'email_template_attachment_id', $form_data["email_template_attachment_id"] );
450
  }
451
  ?>
452
  <div class="updated">
importer.php CHANGED
@@ -110,6 +110,11 @@ function acui_import_users( $file, $form_data, $attach_id = 0, $is_cron = false,
110
  if( count( $data ) == 1 )
111
  $data = $data[0];
112
 
 
 
 
 
 
113
  foreach ( $data as $key => $value ){
114
  $data[ $key ] = preg_replace( '/<script\b[^>]*>(.*?)<\/script>/is', '', trim( $value ) );
115
  }
@@ -578,6 +583,11 @@ function acui_import_users( $file, $form_data, $attach_id = 0, $is_cron = false,
578
  $headers_mail = array();
579
  $headers_mail = apply_filters( 'acui_import_email_headers', $headers_mail, $headers, $data );
580
 
 
 
 
 
 
581
  add_filter( 'wp_mail_content_type', 'cod_set_html_content_type' );
582
 
583
  if( get_option( "acui_settings" ) == "plugin" ){
@@ -585,7 +595,7 @@ function acui_import_users( $file, $form_data, $attach_id = 0, $is_cron = false,
585
  add_filter( 'wp_mail_from', 'acui_mail_from' );
586
  add_filter( 'wp_mail_from_name', 'acui_mail_from_name' );
587
 
588
- wp_mail( apply_filters( 'acui_import_email_to', $email, $headers, $data ), $subject, $body_mail, $headers_mail );
589
 
590
  remove_filter( 'wp_mail_from', 'acui_mail_from' );
591
  remove_filter( 'wp_mail_from_name', 'acui_mail_from_name' );
@@ -651,7 +661,7 @@ function acui_import_users( $file, $form_data, $attach_id = 0, $is_cron = false,
651
  }
652
 
653
  function acui_options(){
654
- global $url_plugin;
655
 
656
  if ( !current_user_can('create_users') ) {
657
  wp_die( __( 'You are not allowed to see this content.', 'import-users-from-csv-with-meta' ));
@@ -696,1046 +706,36 @@ function acui_options(){
696
  acui_admin_tabs('homepage');
697
 
698
  switch ( $tab ){
699
- case 'homepage' :
700
-
701
- $args_old_csv = array( 'post_type'=> 'attachment', 'post_mime_type' => 'text/csv', 'post_status' => 'inherit', 'posts_per_page' => -1 );
702
- $old_csv_files = new WP_Query( $args_old_csv );
703
-
704
- acui_check_options();
705
- ?>
706
- <div class="wrap acui">
707
-
708
- <?php if( $old_csv_files->found_posts > 0 ): ?>
709
- <div class="postbox">
710
- <div title="<?php _e( 'Click to open/close', 'import-users-from-csv-with-meta' ); ?>" class="handlediv">
711
- <br>
712
- </div>
713
-
714
- <h3 class="hndle"><span>&nbsp;&nbsp;&nbsp;<?php _e( 'Old CSV files uploaded', 'import-users-from-csv-with-meta' ); ?></span></h3>
715
-
716
- <div class="inside" style="display: block;">
717
- <p><?php _e( 'For security reasons you should delete this files, probably they would be visible in the Internet if a bot or someone discover the URL. You can delete each file or maybe you want delete all CSV files you have uploaded:', 'import-users-from-csv-with-meta' ); ?></p>
718
- <input type="button" value="<?php _e( 'Delete all CSV files uploaded', 'import-users-from-csv-with-meta' ); ?>" id="bulk_delete_attachment" style="float:right;" />
719
- <ul>
720
- <?php while($old_csv_files->have_posts()) :
721
- $old_csv_files->the_post();
722
-
723
- if( get_the_date() == "" )
724
- $date = "undefined";
725
- else
726
- $date = get_the_date();
727
- ?>
728
- <li><a href="<?php echo wp_get_attachment_url( get_the_ID() ); ?>"><?php the_title(); ?></a> <?php _e( 'uploaded on', 'import-users-from-csv-with-meta' ) . ' ' . $date; ?> <input type="button" value="<?php _e( 'Delete', 'import-users-from-csv-with-meta' ); ?>" class="delete_attachment" attach_id="<?php the_ID(); ?>" /></li>
729
- <?php endwhile; ?>
730
- <?php wp_reset_postdata(); ?>
731
- </ul>
732
- <div style="clear:both;"></div>
733
- </div>
734
- </div>
735
- <?php endif; ?>
736
-
737
- <div id='message' class='updated'><?php _e( 'File must contain at least <strong>2 columns: username and email</strong>. These should be the first two columns and it should be placed <strong>in this order: username and email</strong>. If there are more columns, this plugin will manage it automatically.', 'import-users-from-csv-with-meta' ); ?></div>
738
- <div id='message-password' class='error'><?php _e( 'Please, read carefully how <strong>passwords are managed</strong> and also take note about capitalization, this plugin is <strong>case sensitive</strong>.', 'import-users-from-csv-with-meta' ); ?></div>
739
-
740
- <div>
741
- <h2><?php _e( 'Import users from CSV','import-users-from-csv-with-meta' ); ?></h2>
742
- </div>
743
-
744
- <div style="clear:both;"></div>
745
-
746
- <div class="main_bar">
747
- <form method="POST" enctype="multipart/form-data" action="" accept-charset="utf-8" onsubmit="return check();">
748
- <table class="form-table">
749
- <tbody>
750
- <tr class="form-field form-required">
751
- <th scope="row"><label><?php _e( 'Update existing users?', 'import-users-from-csv-with-meta' ); ?></label></th>
752
- <td>
753
- <select name="update_existing_users">
754
- <option value="yes"><?php _e( 'Yes', 'import-users-from-csv-with-meta' ); ?></option>
755
- <option value="no"><?php _e( 'No', 'import-users-from-csv-with-meta' ); ?></option>
756
- </select>
757
- </td>
758
- </tr>
759
-
760
- <tr class="form-field">
761
- <th scope="row"><label for="role"><?php _e( 'Default role', 'import-users-from-csv-with-meta' ); ?></label></th>
762
- <td>
763
- <?php
764
- $list_roles = acui_get_editable_roles();
765
-
766
- foreach ($list_roles as $key => $value) {
767
- if($key == "subscriber")
768
- echo "<label style='margin-right:5px;'><input name='role[]' type='checkbox' checked='checked' value='$key'/>$value</label>";
769
- else
770
- echo "<label style='margin-right:5px;'><input name='role[]' type='checkbox' value='$key'/>$value</label>";
771
- }
772
- ?>
773
-
774
- <p class="description"><?php _e( 'You can also import roles from a CSV column. Please read documentation tab to see how it can be done. If you choose more than one role, the roles would be assigned correctly but you should use some plugin like <a href="https://wordpress.org/plugins/user-role-editor/">User Role Editor</a> to manage them.', 'import-users-from-csv-with-meta' ); ?></p>
775
- </td>
776
- </tr>
777
-
778
- <tr class="form-field form-required">
779
- <th scope="row"><label><?php _e( 'Update roles for existing users?', 'import-users-from-csv-with-meta' ); ?></label></th>
780
- <td>
781
- <select name="update_roles_existing_users">
782
- <option value="no"><?php _e( 'No', 'import-users-from-csv-with-meta' ); ?></option>
783
- <option value="yes"><?php _e( 'Yes, update and override existing roles', 'import-users-from-csv-with-meta' ); ?></option>
784
- <option value="yes_no_override"><?php _e( 'Yes, add new roles and not override existing ones', 'import-users-from-csv-with-meta' ); ?></option>
785
- </select>
786
- </td>
787
- </tr>
788
-
789
- <tr class="form-field form-required">
790
- <th scope="row"><label><?php _e( 'CSV file <span class="description">(required)</span></label>', 'import-users-from-csv-with-meta' ); ?></th>
791
- <td>
792
- <div id="upload_file">
793
- <input type="file" name="uploadfiles[]" id="uploadfiles" size="35" class="uploadfiles" />
794
- <?php _e( '<em>or you can choose directly a file from your host,', 'import-users-from-csv-with-meta' ) ?> <a href="#" class="toggle_upload_path"><?php _e( 'click here', 'import-users-from-csv-with-meta' ) ?></a>.</em>
795
- </div>
796
- <div id="introduce_path" style="display:none;">
797
- <input placeholder="<?php _e( 'You have to introduce the path to file, i.e.:' ,'import-users-from-csv-with-meta' ); ?><?php $upload_dir = wp_upload_dir(); echo $upload_dir["path"]; ?>/test.csv" type="text" name="path_to_file" id="path_to_file" value="<?php echo dirname( __FILE__ ); ?>/test.csv" style="width:70%;" />
798
- <em><?php _e( 'or you can upload it directly from your PC', 'import-users-from-csv-with-meta' ); ?>, <a href="#" class="toggle_upload_path"><?php _e( 'click here', 'import-users-from-csv-with-meta' ); ?></a>.</em>
799
- </div>
800
- </td>
801
- </tr>
802
-
803
- <tr class="form-field form-required">
804
- <th scope="row"><label><?php _e( 'What should the plugin do with empty cells?', 'import-users-from-csv-with-meta' ); ?></label></th>
805
- <td>
806
- <select name="empty_cell_action">
807
- <option value="leave"><?php _e( 'Leave the old value for this metadata', 'import-users-from-csv-with-meta' ); ?></option>
808
- <option value="delete"><?php _e( 'Delete the metadata', 'import-users-from-csv-with-meta' ); ?></option>
809
- </select>
810
- </td>
811
- </tr>
812
-
813
- <?php if( is_plugin_active( 'buddypress/bp-loader.php' ) ):
814
-
815
- if( !class_exists( "BP_XProfile_Group" ) ){
816
- require_once( WP_PLUGIN_DIR . "/buddypress/bp-xprofile/classes/class-bp-xprofile-group.php" );
817
- }
818
-
819
- $buddypress_fields = array();
820
- $buddypress_types=array();
821
- $profile_groups = BP_XProfile_Group::get( array( 'fetch_fields' => true ) );
822
-
823
- if ( !empty( $profile_groups ) ) {
824
- foreach ( $profile_groups as $profile_group ) {
825
- if ( !empty( $profile_group->fields ) ) {
826
- foreach ( $profile_group->fields as $field ) {
827
- $buddypress_fields[] = $field->name;
828
- $buddypress_types[] = $field->type;
829
- }
830
- }
831
- }
832
- }
833
- ?>
834
-
835
- <tr class="form-field form-required">
836
- <th scope="row"><label><?php _e( 'BuddyPress users', 'import-users-from-csv-with-meta' ); ?></label></th>
837
- <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' ); ?>
838
- <ul style="list-style:disc outside none;margin-left:2em;">
839
- <?php foreach ($buddypress_fields as $buddypress_field ): ?><li><?php echo $buddypress_field; ?></li><?php endforeach; ?>
840
- </ul>
841
- <?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' ); ?>
842
-
843
- <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>
844
- </td>
845
- </tr>
846
-
847
- <?php endif; ?>
848
-
849
- <?php if( is_plugin_active( 'wp-members/wp-members.php' ) ): ?>
850
-
851
- <tr class="form-field form-required">
852
- <th scope="row"><label>Activate user when they are being imported?</label></th>
853
- <td>
854
- <select name="activate_users_wp_members">
855
- <option value="no_activate"><?php _e( 'Do not activate users', 'import-users-from-csv-with-meta' ); ?></option>
856
- <option value="activate"><?php _e( 'Activate users when they are being imported', 'import-users-from-csv-with-meta' ); ?></option>
857
- </select>
858
-
859
- <p class="description"><strong>(<?php _e( 'Only for', 'import-users-from-csv-with-meta' ); ?> <a href="https://wordpress.org/plugins/wp-members/"><?php _e( 'WP Members', 'import-users-from-csv-with-meta' ); ?></a> <?php _e( 'users', 'import-users-from-csv-with-meta' ); ?>)</strong>.</p>
860
- </td>
861
-
862
- </tr>
863
-
864
- <?php endif; ?>
865
-
866
- <?php if( is_plugin_active( 'new-user-approve/new-user-approve.php' ) ): ?>
867
-
868
- <tr class="form-field form-required">
869
- <th scope="row"><label><?php _e( 'Approve users at the same time is being created', 'import-users-from-csv-with-meta' ); ?></label></th>
870
- <td>
871
- <select name="approve_users_new_user_appove">
872
- <option value="no_approve"><?php _e( 'Do not approve users', 'import-users-from-csv-with-meta' ); ?></option>
873
- <option value="approve"><?php _e( 'Approve users when they are being imported', 'import-users-from-csv-with-meta' ); ?></option>
874
- </select>
875
-
876
- <p class="description"><strong>(<?php _e( 'Only for', 'import-users-from-csv-with-meta' ); ?> <a href="https://es.wordpress.org/plugins/new-user-approve/"><?php _e( 'New User Approve', 'import-users-from-csv-with-meta' ); ?></a> <?php _e( 'users', 'import-users-from-csv-with-meta' ); ?></strong>.</p>
877
- </td>
878
-
879
- </tr>
880
-
881
- <?php endif; ?>
882
-
883
- <?php if( is_plugin_active( 'allow-multiple-accounts/allow-multiple-accounts.php' ) ): ?>
884
-
885
- <tr class="form-field form-required">
886
- <th scope="row"><label><?php _e( 'Repeated email in different users?', 'import-users-from-csv-with-meta' ); ?></label></th>
887
- <td>
888
- <select name="allow_multiple_accounts">
889
- <option value="not_allowed"><?php _e( 'Not allowed', 'import-users-from-csv-with-meta' ); ?></option>
890
- <option value="allowed"><?php _e( 'Allowed', 'import-users-from-csv-with-meta' ); ?></option>
891
- </select>
892
- <p class="description"><strong>(<?php _e( 'Only for', 'import-users-from-csv-with-meta' ); ?> <a href="https://wordpress.org/plugins/allow-multiple-accounts/"><?php _e( 'Allow Multiple Accounts', 'import-users-from-csv-with-meta' ); ?></a> <?php _e( 'users', 'import-users-from-csv-with-meta'); ?>)</strong>. <?php _e('Allow multiple user accounts to be created having the same email address.','import-users-from-csv-with-meta' ); ?></p>
893
- </td>
894
- </tr>
895
-
896
- <?php endif; ?>
897
-
898
- <?php if( is_plugin_active( 'wp-access-areas/wp-access-areas.php' ) ): ?>
899
-
900
- <tr class="form-field form-required">
901
- <th scope="row"><label><?php _e('WordPress Access Areas is activated','import-users-from-csv-with-meta'); ?></label></th>
902
- <td>
903
- <p class="description"><?php _e('As user of','import-users-from-csv-with-meta' ); ?> <a href="https://wordpress.org/plugins/wp-access-areas/"><?php _e( 'WordPress Access Areas', 'import-users-from-csv-with-meta' )?></a> <?php _e( 'you can use the Access Areas created', 'import-users-from-csv-with-meta' ); ?> <a href="<?php echo admin_url( 'users.php?page=user_labels' ); ?>"><?php _e( 'here', 'import-users-from-csv-with-meta' ); ?></a> <?php _e( 'and use this areas in your own CSV file. Please use the column name <strong>wp-access-areas</strong> and in each row use <strong>the name that you have used', 'import-users-from-csv-with-meta' ); ?> <a href="<?php echo admin_url( 'users.php?page=user_labels' ); ?>"><?php _e( 'here', 'import-users-from-csv-with-meta' ); ?></a></strong><?php _e( ', like this ones:', 'import-users-from-csv-with-meta' ); ?></p>
904
- <ol>
905
- <?php
906
- $data = WPAA_AccessArea::get_available_userlabels( '0,5' , NULL );
907
- foreach ( $data as $access_area_object ): ?>
908
- <li><?php echo $access_area_object->cap_title; ?></li>
909
- <?php endforeach; ?>
910
-
911
- </ol>
912
- <p class="description"><?php _e( "If you leave this cell empty for some user or the access area indicated doesn't exist, user won't be assigned to any access area. You can choose more than one area for each user using pads between them in the same row, i.e.: ", 'import-users-from-csv-with-meta' ) ?>access_area1#accces_area2</p>
913
- </td>
914
- </tr>
915
-
916
- <?php endif; ?>
917
-
918
- <tr class="form-field">
919
- <th scope="row"><label for="user_login"><?php _e( 'Send mail', 'import-users-from-csv-with-meta' ); ?></label></th>
920
- <td>
921
- <p>
922
- <?php _e( 'Do you wish to send a mail with credentials and other data?', 'import-users-from-csv-with-meta' ); ?>
923
- <input type="checkbox" name="sends_email" value="yes" <?php if( get_option( 'acui_manually_send_mail' ) ): ?> checked="checked" <?php endif; ?>>
924
- </p>
925
- <p>
926
- <?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' ); ?>
927
- <input type="checkbox" name="send_email_updated" value="yes" <?php if( get_option( 'acui_manually_send_mail_updated' ) ): ?> checked="checked" <?php endif; ?>>
928
- </p>
929
- </td>
930
- </tr>
931
- </tbody>
932
- </table>
933
-
934
- <?php wp_nonce_field( 'acui-import', 'acui-nonce' ); ?>
935
-
936
- <input class="button-primary" type="submit" name="uploadfile" id="uploadfile_btn" value="<?php _e( 'Start importing', 'import-users-from-csv-with-meta' ); ?>"/>
937
- </form>
938
- </div>
939
-
940
- <div class="sidebar">
941
- <div class="sidebar_section become_patreon">
942
- <a class="patreon" color="primary" type="button" name="become-a-patron" data-tag="become-patron-button" href="https://www.patreon.com/bePatron?c=1741454" role="button">
943
- <div><span><?php _e( 'Become a patron', 'import-users-from-csv-with-meta'); ?></span></div>
944
- </a>
945
- </div>
946
-
947
- <?php if( substr( get_locale(), 0, 2 ) == 'es' ): ?>
948
- <div class="sidebar_section" id="webempresa">
949
- <h3>Tu web más rápida con Webempresa</h3>
950
- <ul>
951
- <li><label>Además ahora un <a href="https://codection.com/25-de-descuento-en-el-mejor-hosting-en-espanol-con-webempresa/">25% de descuento</a>.</label></li>
952
- </ul>
953
- <a href="https://codection.com/25-de-descuento-en-el-mejor-hosting-en-espanol-con-webempresa/" target="_blank">
954
- <img src="<?php echo plugin_dir_url( __FILE__ ); ?>assets/webempresa_logo.png">
955
- </a>
956
- </div>
957
- <?php else: ?>
958
- <div class="sidebar_section" style="padding:0 !important;border:none !important;background:none !important;">
959
- <a href="https://codection.com/how-to-transfer-your-website-to-inmotion-hosting/" target="_blank">
960
- <img src="<?php echo plugin_dir_url( __FILE__ ); ?>assets/codection-inmotion.png">
961
- </a>
962
- </div>
963
- <?php endif; ?>
964
-
965
- <div class="sidebar_section" id="vote_us">
966
- <h3>Rate Us</h3>
967
- <ul>
968
- <li><label>If you like it, Please vote and support us.</label></li>
969
- </ul>
970
- </div>
971
- <div class="sidebar_section">
972
- <h3>Having Issues?</h3>
973
- <ul>
974
- <li><label>You can create a ticket</label> <a target="_blank" href="http://wordpress.org/support/plugin/import-users-from-csv-with-meta"><label>WordPress support forum</label></a></li>
975
- <li><label>You can ask for premium support</label> <a target="_blank" href="mailto:contacto@codection.com"><label>contacto@codection.com</label></a></li>
976
- </ul>
977
- </div>
978
- <div class="sidebar_section">
979
- <h3>Donate</h3>
980
- <ul>
981
- <li><label>If you appreciate our work and you want to help us to continue developing it and giving the best support</label> <a target="_blank" href="https://paypal.me/imalrod"><label>donate</label></a></li>
982
- </ul>
983
- </div>
984
- </div>
985
-
986
- </div>
987
- <script type="text/javascript">
988
- function check(){
989
- if(document.getElementById("uploadfiles").value == "" && jQuery( "#upload_file" ).is(":visible") ) {
990
- alert("<?php _e( 'Please choose a file', 'import-users-from-csv-with-meta' ); ?>");
991
- return false;
992
- }
993
-
994
- if( jQuery( "#path_to_file" ).val() == "" && jQuery( "#introduce_path" ).is(":visible") ) {
995
- alert("<?php _e( 'Please enter a path to the file', 'import-users-from-csv-with-meta' ); ?>");
996
- return false;
997
- }
998
-
999
- if( jQuery("[name=role\\[\\]]input:checkbox:checked").length == 0 ){
1000
- alert("<?php _e( 'Please select a role', 'import-users-from-csv-with-meta'); ?>");
1001
- return false;
1002
- }
1003
- }
1004
-
1005
- jQuery( document ).ready( function( $ ){
1006
- $( ".delete_attachment" ).click( function(){
1007
- var answer = confirm( "<?php _e( 'Are you sure to delete this file?', 'import-users-from-csv-with-meta' ); ?>" );
1008
- if( answer ){
1009
- var data = {
1010
- 'action': 'acui_delete_attachment',
1011
- 'attach_id': $( this ).attr( "attach_id" )
1012
- };
1013
-
1014
- $.post(ajaxurl, data, function(response) {
1015
- if( response != 1 )
1016
- alert( "<?php _e( 'There were problems deleting the file, please check file permissions', 'import-users-from-csv-with-meta' ); ?>" );
1017
- else{
1018
- alert( "<?php _e( 'File successfully deleted', 'import-users-from-csv-with-meta' ); ?>" );
1019
- document.location.reload();
1020
- }
1021
- });
1022
- }
1023
- });
1024
-
1025
- $( "#bulk_delete_attachment" ).click( function(){
1026
- var answer = confirm( "<?php _e( 'Are you sure to delete ALL CSV files uploaded? There can be CSV files from other plugins.', 'import-users-from-csv-with-meta' ); ?>" );
1027
- if( answer ){
1028
- var data = {
1029
- 'action': 'acui_bulk_delete_attachment',
1030
- };
1031
-
1032
- $.post(ajaxurl, data, function(response) {
1033
- if( response != 1 )
1034
- alert( "<?php _e( 'There were problems deleting the files, please check files permissions', 'import-users-from-csv-with-meta' ); ?>" );
1035
- else{
1036
- alert( "<?php _e( 'Files successfully deleted', 'import-users-from-csv-with-meta' ); ?>" );
1037
- document.location.reload();
1038
- }
1039
- });
1040
- }
1041
- });
1042
-
1043
- $( ".toggle_upload_path" ).click( function( e ){
1044
- e.preventDefault();
1045
-
1046
- $("#upload_file,#introduce_path").toggle();
1047
- } );
1048
-
1049
- $("#vote_us").click(function(){
1050
- var win=window.open("http://wordpress.org/support/view/plugin-reviews/import-users-from-csv-with-meta?free-counter?rate=5#postform", '_blank');
1051
- win.focus();
1052
- });
1053
-
1054
- } );
1055
- </script>
1056
-
1057
- <?php
1058
-
1059
- break;
1060
-
1061
- case 'frontend':
1062
-
1063
- $send_mail_frontend = get_option( "acui_frontend_send_mail");
1064
- $send_mail_updated_frontend = get_option( "acui_frontend_send_mail_updated");
1065
- $role = get_option( "acui_frontend_role");
1066
- $activate_users_wp_members = get_option( "acui_frontend_activate_users_wp_members");
1067
-
1068
- if( empty( $send_mail_frontend ) )
1069
- $send_mail_frontend = false;
1070
-
1071
- if( empty( $send_mail_updated_frontend ) )
1072
- $send_mail_updated_frontend = false;
1073
- ?>
1074
- <h3><?php _e( "Execute an import of users in the frontend", 'import-users-from-csv-with-meta' ); ?></h3>
1075
-
1076
- <form method="POST" enctype="multipart/form-data" action="" accept-charset="utf-8">
1077
- <table class="form-table">
1078
- <tbody>
1079
- <tr class="form-field">
1080
- <th scope="row"><label for=""><?php _e( 'Use this shortcode in any page or post', 'import-users-from-csv-with-meta' ); ?></label></th>
1081
- <td>
1082
- <pre>[import-users-from-csv-with-meta]</pre>
1083
- <input class="button-primary" type="button" id="copy_to_clipboard" value="<?php _e( 'Copy to clipboard', 'import-users-from-csv-with-meta'); ?>"/>
1084
- </td>
1085
- </tr>
1086
- <tr class="form-field form-required">
1087
- <th scope="row"><label for="send-mail-frontend"><?php _e( 'Send mail when using frontend import?', 'import-users-from-csv-with-meta' ); ?></label></th>
1088
- <td>
1089
- <input type="checkbox" name="send-mail-frontend" value="yes" <?php if( $send_mail_frontend == true ) echo "checked='checked'"; ?>/>
1090
- </td>
1091
- </tr>
1092
- <tr class="form-field form-required">
1093
- <th scope="row"><label for="send-mail-updated-frontend"><?php _e( 'Send mail also to users that are being updated?', 'import-users-from-csv-with-meta' ); ?></label></th>
1094
- <td>
1095
- <input type="checkbox" name="send-mail-updated-frontend" value="yes" <?php if( $send_mail_updated_frontend == true ) echo "checked='checked'"; ?>/>
1096
- </td>
1097
- </tr>
1098
- <tr class="form-field form-required">
1099
- <th scope="row"><label for="role"><?php _e( 'Role', 'import-users-from-csv-with-meta' ); ?></label></th>
1100
- <td>
1101
- <select id="role-frontend" name="role-frontend">
1102
- <?php
1103
- if( $role == '' )
1104
- echo "<option selected='selected' value=''>" . __( 'Disable role assignement in frontend import', 'import-users-from-csv-with-meta' ) . "</option>";
1105
- else
1106
- echo "<option value=''>" . __( 'Disable role assignement in frontend import', 'import-users-from-csv-with-meta' ) . "</option>";
1107
-
1108
- $list_roles = acui_get_editable_roles();
1109
- foreach ($list_roles as $key => $value) {
1110
- if($key == $role)
1111
- echo "<option selected='selected' value='$key'>$value</option>";
1112
- else
1113
- echo "<option value='$key'>$value</option>";
1114
- }
1115
- ?>
1116
- </select>
1117
- <p class="description"><?php _e( 'Which role would be used to import users?', 'import-users-from-csv-with-meta' ); ?></p>
1118
- </td>
1119
- </tr>
1120
-
1121
- <?php if( is_plugin_active( 'wp-members/wp-members.php' ) ): ?>
1122
-
1123
- <tr class="form-field form-required">
1124
- <th scope="row"><label>Activate user when they are being imported?</label></th>
1125
- <td>
1126
- <select name="activate_users_wp_members">
1127
- <option value="no_activate" <?php selected( $activate_users_wp_members,'no_activate', true ); ?>><?php _e( 'Do not activate users', 'import-users-from-csv-with-meta' ); ?></option>
1128
- <option value="activate" <?php selected( $activate_users_wp_members,'activate', true ); ?>><?php _e( 'Activate users when they are being imported', 'import-users-from-csv-with-meta' ); ?></option>
1129
- </select>
1130
-
1131
- <p class="description"><strong>(<?php _e( 'Only for', 'import-users-from-csv-with-meta' ); ?> <a href="https://wordpress.org/plugins/wp-members/"><?php _e( 'WP Members', 'import-users-from-csv-with-meta' ); ?></a> <?php _e( 'users', 'import-users-from-csv-with-meta' ); ?>)</strong>.</p>
1132
- </td>
1133
- </tr>
1134
-
1135
- <?php endif; ?>
1136
- </tbody>
1137
- </table>
1138
- <input class="button-primary" type="submit" value="<?php _e( 'Save frontend import options', 'import-users-from-csv-with-meta'); ?>"/>
1139
- </form>
1140
-
1141
- <script>
1142
- jQuery( document ).ready( function( $ ){
1143
- $( '#copy_to_clipboard' ).click( function(){
1144
- var $temp = $("<input>");
1145
- $("body").append($temp);
1146
- $temp.val( '[import-users-from-csv-with-meta]' ).select();
1147
- document.execCommand("copy");
1148
- $temp.remove();
1149
- } );
1150
- });
1151
- </script>
1152
- <?php break;
1153
-
1154
- case 'columns':
1155
- $show_profile_fields = get_option( "acui_show_profile_fields");
1156
- $headers = get_option("acui_columns");
1157
- ?>
1158
-
1159
- <h3><?php _e( 'Extra profile fields', 'import-users-from-csv-with-meta' ); ?></h3>
1160
- <table class="form-table">
1161
- <tbody>
1162
- <tr valign="top">
1163
- <th scope="row"><?php _e( 'Show fields in profile?', 'import-users-from-csv-with-meta' ); ?></th>
1164
- <td>
1165
- <form method="POST" enctype="multipart/form-data" action="" accept-charset="utf-8">
1166
- <input type="checkbox" name="show-profile-fields" value="yes" <?php if( $show_profile_fields == true ) echo "checked='checked'"; ?>>
1167
- <input type="hidden" name="show-profile-fields-action" value="update"/>
1168
- <input class="button-primary" type="submit" value="<?php _e( 'Save option', 'import-users-from-csv-with-meta'); ?>"/>
1169
- </form>
1170
- </td>
1171
- </tr>
1172
- <tr valign="top">
1173
- <th scope="row"><?php _e( 'Extra profile fields loadad in previous files', 'import-users-from-csv-with-meta' ); ?></th>
1174
- <td><small><em><?php _e( '(if you load another CSV with different columns, the new ones will replace this list)', 'import-users-from-csv-with-meta' ); ?></em></small>
1175
- <ol>
1176
- <?php
1177
- if( is_array( $headers ) && count( $headers ) > 0 ):
1178
- foreach ($headers as $column): ?>
1179
- <li><?php echo $column; ?></li>
1180
- <?php endforeach; ?>
1181
-
1182
- <?php else: ?>
1183
- <li><?php _e( 'There is no columns loaded yet', 'import-users-from-csv-with-meta' ); ?></li>
1184
- <?php endif; ?>
1185
- </ol>
1186
- </td>
1187
- </tr>
1188
- </tbody></table>
1189
 
1190
- <?php
 
 
1191
 
 
 
1192
  break;
1193
 
1194
  case 'doc':
 
 
1195
 
1196
- ?>
1197
-
1198
- <h3><?php _e( 'Documentation', 'import-users-from-csv-with-meta' ); ?></h3>
1199
- <table class="form-table">
1200
- <tbody>
1201
- <tr valign="top">
1202
- <th scope="row"><?php _e( 'Columns position', 'import-users-from-csv-with-meta' ); ?></th>
1203
- <td><small><em><?php _e( '(Documents should look like the one presented into screenshot. Remember you should fill the first two columns with the next values)', 'import-users-from-csv-with-meta' ); ?></em></small>
1204
- <ol>
1205
- <li><?php _e( 'Username', 'import-users-from-csv-with-meta' ); ?></li>
1206
- <li><?php _e( 'Email', 'import-users-from-csv-with-meta' ); ?></li>
1207
- </ol>
1208
- <small><em><?php _e( '(The next columns are totally customizable and you can use whatever you want. All rows must contains same columns)', 'import-users-from-csv-with-meta' ); ?></em></small>
1209
- <small><em><?php _e( '(User profile will be adapted to the kind of data you have selected)', 'import-users-from-csv-with-meta' ); ?></em></small>
1210
- <small><em><?php _e( '(If you want to disable the extra profile information, please deactivate this plugin after make the import)', 'import-users-from-csv-with-meta' ); ?></em></small>
1211
- </td>
1212
- </tr>
1213
- <tr valign="top">
1214
- <th scope="row"><?php _e( 'id', 'import-users-from-csv-with-meta' ); ?></th>
1215
- <td><?php _e( 'You can use a column called id in order to make inserts or updates of an user using the ID used by WordPress in the wp_users table. We have two different cases:', 'import-users-from-csv-with-meta' ); ?>
1216
- <ul style="list-style:disc outside none; margin-left:2em;">
1217
- <li><?php _e( "If id <strong>doesn't exist in your users table</strong>: WordPress core does not allow us insert it, so it will throw an error of kind: invalid_user_id", 'import-users-from-csv-with-meta' ); ?></li>
1218
- <li><?php _e( "If id <strong>exists</strong>: plugin check if username is the same, if yes, it will update the data, if not, it ignores the cell to avoid problems", 'import-users-from-csv-with-meta' ); ?></li>
1219
- </ul>
1220
- </td>
1221
- </tr>
1222
- <tr valign="top">
1223
- <th scope="row"><?php _e( "Passwords", 'import-users-from-csv-with-meta' ); ?></th>
1224
- <td><?php _e( "A string that contains user passwords. We have different options for this case:", 'import-users-from-csv-with-meta' ); ?>
1225
- <ul style="list-style:disc outside none; margin-left:2em;">
1226
- <li><?php _e( "If you <strong>don't create a column for passwords</strong>: passwords will be generated automatically", 'import-users-from-csv-with-meta' ); ?></li>
1227
- <li><?php _e( "If you <strong>create a column for passwords</strong>: if cell is empty, password won't be updated; if cell has a value, it will be used", 'import-users-from-csv-with-meta' ); ?></li>
1228
- </ul>
1229
- </td>
1230
- </tr>
1231
- <tr valign="top">
1232
- <th scope="row"><?php _e( "Roles", 'import-users-from-csv-with-meta' ); ?></th>
1233
- <td><?php _e( "Plugin can import roles from the CSV. This is how it works:", 'import-users-from-csv-with-meta' ); ?>
1234
- <ul style="list-style:disc outside none; margin-left:2em;">
1235
- <li><?php _e( "If you <strong>don't create a column for roles</strong>: roles would be chosen from the 'Default role' field in import screen.", 'import-users-from-csv-with-meta' ); ?></li>
1236
- <li><?php _e( "If you <strong>create a column called 'role'</strong>: if cell is empty, roles would be chosen from 'Default role' field in import screen; if cell has a value, it will be used as role, if this role doesn't exist the default one would be used", 'import-users-from-csv-with-meta' ); ?></li>
1237
- <li><?php _e( "Multiple roles can be imported creating <strong>a list of roles</strong> using commas to separate values.", 'import-users-from-csv-with-meta' ); ?></li>
1238
- </ul>
1239
- <em><?php _e( "Notice: If the default new role is administrator in WordPress settings, role will not be set during a CSV file import with this plugin. Check it if all users are being imported as administrators and you have set another role in this plugin.", 'import-users-from-csv-with-meta' ); ?></em>
1240
- </td>
1241
- </tr>
1242
- <tr valign="top">
1243
- <th scope="row"><?php _e( "Serialized data", 'import-users-from-csv-with-meta' ); ?></th>
1244
- <td><?php _e( "Plugin can now import serialized data. You have to use the serialized string directly in the CSV cell in order the plugin will be able to understand it as an serialized data instead as any other string.", 'import-users-from-csv-with-meta' ); ?>
1245
- </td>
1246
- </tr>
1247
- <tr valign="top">
1248
- <th scope="row"><?php _e( "Lists", 'import-users-from-csv-with-meta' ); ?></th>
1249
- <td><?php _e( "Plugin can now import lists an array. Use this separator:", 'import-users-from-csv-with-meta'); ?> <strong>::</strong> <?php _e("two colons, inside the cell in order to split the string in a list of items.", 'import-users-from-csv-with-meta' ); ?>
1250
- </td>
1251
- </tr>
1252
- <tr valign="top">
1253
- <th scope="row"><?php _e( 'WordPress default profile data', 'import-users-from-csv-with-meta' ); ?></th>
1254
- <td><?php _e( "You can use those labels if you want to set data adapted to the WordPress default user columns (the ones who use the function", 'import-users-from-csv-with-meta' ); ?> <a href="http://codex.wordpress.org/Function_Reference/wp_update_user">wp_update_user</a>)
1255
- <ol>
1256
- <li><strong>user_nicename</strong>: <?php _e( "A string that contains a URL-friendly name for the user. The default is the user's username.", 'import-users-from-csv-with-meta' ); ?></li>
1257
- <li><strong>user_url</strong>: <?php _e( "A string containing the user's URL for the user's web site.", 'import-users-from-csv-with-meta' ); ?> </li>
1258
- <li><strong>display_name</strong>: <?php _e( "A string that will be shown on the site. Defaults to user's username. It is likely that you will want to change this, for both appearance and security through obscurity (that is if you don't use and delete the default admin user).", 'import-users-from-csv-with-meta' ); ?></li>
1259
- <li><strong>nickname</strong>: <?php _e( "The user's nickname, defaults to the user's username.", 'import-users-from-csv-with-meta' ); ?> </li>
1260
- <li><strong>first_name</strong>: <?php _e( "The user's first name.", 'import-users-from-csv-with-meta' ); ?></li>
1261
- <li><strong>last_name</strong>: <?php _e("The user's last name.", 'import-users-from-csv-with-meta' ); ?></li>
1262
- <li><strong>description</strong>: <?php _e("A string containing content about the user.", 'import-users-from-csv-with-meta' ); ?></li>
1263
- <li><strong>jabber</strong>: <?php _e("User's Jabber account.", 'import-users-from-csv-with-meta' ); ?></li>
1264
- <li><strong>aim</strong>: <?php _e("User's AOL IM account.", 'import-users-from-csv-with-meta' ); ?></li>
1265
- <li><strong>yim</strong>: <?php _e("User's Yahoo IM account.", 'import-users-from-csv-with-meta' ); ?></li>
1266
- <li><strong>user_registered</strong>: <?php _e( "Using the WordPress format for this kind of data Y-m-d H:i:s.", "import-users-from-csv-with-meta "); ?></li>
1267
- </ol>
1268
- </td>
1269
- </tr>
1270
-
1271
- <?php if( is_plugin_active( 'woocommerce/woocommerce.php' ) ): ?>
1272
-
1273
- <tr valign="top">
1274
- <th scope="row"><?php _e( "WooCommerce is activated", 'import-users-from-csv-with-meta' ); ?></th>
1275
- <td><?php _e( "You can use those labels if you want to set data adapted to the WooCommerce default user columns", 'import-users-from-csv-with-meta' ); ?>
1276
- <ol>
1277
- <li>billing_first_name</li>
1278
- <li>billing_last_name</li>
1279
- <li>billing_company</li>
1280
- <li>billing_address_1</li>
1281
- <li>billing_address_2</li>
1282
- <li>billing_city</li>
1283
- <li>billing_postcode</li>
1284
- <li>billing_country</li>
1285
- <li>billing_state</li>
1286
- <li>billing_phone</li>
1287
- <li>billing_email</li>
1288
- <li>shipping_first_name</li>
1289
- <li>shipping_last_name</li>
1290
- <li>shipping_company</li>
1291
- <li>shipping_address_1</li>
1292
- <li>shipping_address_2</li>
1293
- <li>shipping_city</li>
1294
- <li>shipping_postcode</li>
1295
- <li>shipping_country</li>
1296
- <li>shipping_state</li>
1297
- </ol>
1298
- </td>
1299
- </tr>
1300
- <?php endif; ?>
1301
-
1302
- <?php if( is_plugin_active( 'buddypress/bp-loader.php' ) ): ?>
1303
-
1304
- <tr valign="top">
1305
- <th scope="row"><?php _e( "BuddyPress is activated", 'import-users-from-csv-with-meta' ); ?></th>
1306
- <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' ); ?>
1307
- <ul style="list-style:disc outside none; margin-left:2em;">
1308
- <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>
1309
- <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>
1310
- <li><?php _e( "And the role assigned in this group: <em>Administrator, Moderator or Member</em>", 'import-users-from-csv-with-meta' ); ?></li>
1311
- <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>
1312
- <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>
1313
- <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>
1314
- </ul>
1315
- </td>
1316
- </tr>
1317
-
1318
- <?php endif; ?>
1319
-
1320
- <?php do_action( 'acui_documentation_after_plugins_activated' ); ?>
1321
-
1322
- <tr valign="top">
1323
- <th scope="row"><?php _e( "Important notice", 'import-users-from-csv-with-meta' ); ?></th>
1324
- <td><?php _e( "You can upload as many files as you want, but all must have the same columns. If you upload another file, the columns will change to the form of last file uploaded.", 'import-users-from-csv-with-meta' ); ?></td>
1325
- </tr>
1326
- <tr valign="top">
1327
- <th scope="row"><?php _e( "Any question about it", 'import-users-from-csv-with-meta' ); ?></th>
1328
- <td>
1329
- <ul style="list-style:disc outside none; margin-left:2em;">
1330
- <li><?php _e( 'Free support (in WordPress forums):', 'import-users-from-csv-with-meta' ); ?> <a href="https://wordpress.org/support/plugin/import-users-from-csv-with-meta">https://wordpress.org/support/plugin/import-users-from-csv-with-meta</a>.</li>
1331
- <li><?php _e( 'Premium support (with a quote):', 'import-users-from-csv-with-meta' ); ?> <a href="mailto:contacto@codection.com">contacto@codection.com</a>.</li>
1332
- </ul>
1333
- </td>
1334
- </tr>
1335
- <tr valign="top">
1336
- <th scope="row"><?php _e( 'Example', 'import-users-from-csv-with-meta' ); ?></th>
1337
- <td><?php _e( 'Download this', 'import-users-from-csv-with-meta' ); ?> <a href="<?php echo plugins_url() . "/import-users-from-csv-with-meta/test.csv"; ?>">.csv <?php _e('file','import-users-from-csv-with-meta'); ?></a> <?php _e( 'to test', 'import-users-from-csv-with-meta' ); ?></td>
1338
- </tr>
1339
- </tbody>
1340
- </table>
1341
- <br/>
1342
- <div style="width:775px;margin:0 auto"><img src="<?php echo plugins_url() . "/import-users-from-csv-with-meta/csv_example.png"; ?>"/></div>
1343
- <?php break; ?>
1344
-
1345
- <?php case 'mail-options':
1346
- $from_email = get_option( "acui_mail_from" );
1347
- $from_name = get_option( "acui_mail_from_name" );
1348
- $body_mail = get_option( "acui_mail_body" );
1349
- $subject_mail = get_option( "acui_mail_subject" );
1350
- $template_id = get_option( "acui_mail_template_id" );
1351
- $enable_email_templates = get_option( "acui_enable_email_templates" );
1352
- $automattic_wordpress_email = get_option( "acui_automattic_wordpress_email" );
1353
- ?>
1354
- <form method="POST" enctype="multipart/form-data" action="" accept-charset="utf-8">
1355
- <h3><?php _e('Mail options','import-users-from-csv-with-meta'); ?></h3>
1356
-
1357
- <p class="description"><?php _e( 'You can set your own SMTP and other mail details', 'import-users-from-csv-with-meta' ); ?> <a href="<?php echo admin_url( 'tools.php?page=acui-smtp' ); ?>" target="_blank"><?php _e( 'here', 'import-users-from-csv-with-meta' ); ?></a>.
1358
-
1359
- <table class="optiontable form-table">
1360
- <tbody>
1361
- <tr valign="top">
1362
- <th scope="row"><?php _e( 'WordPress automatic emails users updated', 'import-users-from-csv-with-meta' ); ?></th>
1363
- <td>
1364
- <fieldset>
1365
- <legend class="screen-reader-text">
1366
- <span><?php _e( 'Send automattic WordPress emails?', 'import-users-from-csv-with-meta' ); ?></span>
1367
- </legend>
1368
- <label for="automattic_wordpress_email">
1369
- <select name="automattic_wordpress_email" id="automattic_wordpress_email">
1370
- <option <?php if( $automattic_wordpress_email == 'false' ) echo "selected='selected'"; ?> value="false"><?php _e( "Deactivate WordPress automattic email when an user is updated or his password is changed", 'import-users-from-csv-with-meta' ) ;?></option>
1371
- <option <?php if( $automattic_wordpress_email == 'true' ) echo "selected='selected'"; ?> value="true"><?php _e( 'Activate WordPress automattic email when an user is updated or his password is changed', 'import-users-from-csv-with-meta' ); ?></option>
1372
- </select>
1373
- <span class="description"><? _e( "When you update an user or change his password, WordPress prepare and send automattic email, you can deactivate it here.", 'import-users-from-csv-with-meta' ); ?></span>
1374
- </label>
1375
- </fieldset>
1376
- </td>
1377
- </tr>
1378
- <tr valign="top">
1379
- <th scope="row"><?php _e( 'Enable mail templates:', 'import-users-from-csv-with-meta' ); ?></th>
1380
- <td>
1381
- <fieldset>
1382
- <legend class="screen-reader-text">
1383
- <span><?php _e( 'Do you want to enable mail templates?', 'import-users-from-csv-with-meta' ); ?></span>
1384
- </legend>
1385
- <label for="enable_email_templates">
1386
- <input id="enable_email_templates" name="enable_email_templates" value="yes" type="checkbox" <?php checked( $enable_email_templates ); ?>>
1387
- <span class="description"><? _e( "If you activate it, a new option in the menu will be created to store and manage mail templates, instead of using only the next one.", 'import-users-from-csv-with-meta' ); ?></span>
1388
- </label>
1389
- </fieldset>
1390
- </td>
1391
- </tr>
1392
- </tbody>
1393
- </table>
1394
-
1395
- <?php if( $enable_email_templates && wp_count_posts( 'acui_email_template' )->publish > 0 ): ?>
1396
- <h3><?php _e( 'Load custom email from email templates', 'import-users-from-csv-with-meta' ); ?></h3>
1397
- <?php wp_dropdown_pages( array( 'id' => 'email_template_selected', 'post_type' => 'acui_email_template', 'selected' => $template_id ) ); ?>
1398
- <input id="load_email_template" class="button-primary" type="button" value="<?php _e( "Load subject and content from this email template", 'import-users-from-csv-with-meta' ); ?>"/>
1399
- <?php endif; ?>
1400
-
1401
- <h3><?php _e( 'Customize the email that can be sent when importing users', 'import-users-from-csv-with-meta' ); ?></h3>
1402
-
1403
- <p><?php _e( 'Mail subject :', 'import-users-from-csv-with-meta' ); ?><input name="subject_mail" size="100" value="<?php echo $subject_mail; ?>" id="title" autocomplete="off" type="text"></p>
1404
- <?php wp_editor( $body_mail, 'body_mail'); ?>
1405
- <input type="hidden" id="template_id" name="template_id" value="<?php echo $template_id; ?>"/>
1406
-
1407
- <br/>
1408
- <input class="button-primary" type="submit" value="Save mail template and options" id="save_mail_template_options"/>
1409
-
1410
- <?php acui_email_templates_edit_form_after_editor(); ?>
1411
-
1412
- </form>
1413
-
1414
- <script type="text/javascript">
1415
- jQuery( document ).ready( function( $ ){
1416
- $( '#enable_email_templates' ).change( function(){
1417
- var enable = $( this ).is( ':checked' );
1418
- var data = {
1419
- 'action': 'acui_refresh_enable_email_templates',
1420
- 'enable': enable,
1421
- 'security': '<?php echo wp_create_nonce( "codection-security" ); ?>',
1422
- };
1423
-
1424
- $.post( ajaxurl, data, function( response ) {
1425
- location.reload();
1426
- });
1427
- } );
1428
-
1429
- $( '#load_email_template' ).click( function(){
1430
- if( $( '#email_template_selected' ).val() == '' )
1431
- return;
1432
-
1433
- var data = {
1434
- 'action': 'acui_email_template_selected',
1435
- 'email_template_selected': $( '#email_template_selected' ).val(),
1436
- 'security': '<?php echo wp_create_nonce( "codection-security" ); ?>',
1437
- };
1438
-
1439
- $.post( ajaxurl, data, function( response ) {
1440
- console.log( response );
1441
- var response = JSON.parse( response );
1442
- $( '#title' ).val( response.title );
1443
- tinyMCE.get( 'body_mail' ).setContent( response.content );
1444
- $( '#template_id' ).val( response.id );
1445
- $( '#save_mail_template_options' ).click();
1446
- });
1447
- } );
1448
- } );
1449
- </script>
1450
- <?php break; ?>
1451
-
1452
- <?php case 'smtp-settings': ?>
1453
-
1454
- <?php acui_smtp(); ?>
1455
-
1456
- <?php break; ?>
1457
-
1458
- <?php case 'cron':
1459
-
1460
- $cron_activated = get_option( "acui_cron_activated");
1461
- $send_mail_cron = get_option( "acui_cron_send_mail");
1462
- $send_mail_updated = get_option( "acui_cron_send_mail_updated");
1463
- $cron_delete_users = get_option( "acui_cron_delete_users");
1464
- $cron_delete_users_assign_posts = get_option( "acui_cron_delete_users_assign_posts");
1465
- $path_to_file = get_option( "acui_cron_path_to_file");
1466
- $period = get_option( "acui_cron_period");
1467
- $role = get_option( "acui_cron_role");
1468
- $update_roles_existing_users = get_option( "acui_cron_update_roles_existing_users");
1469
- $move_file_cron = get_option( "acui_move_file_cron");
1470
- $path_to_move = get_option( "acui_cron_path_to_move");
1471
- $path_to_move_auto_rename = get_option( "acui_cron_path_to_move_auto_rename");
1472
- $log = get_option( "acui_cron_log");
1473
- $allow_multiple_accounts = get_option("acui_cron_allow_multiple_accounts");
1474
- $loaded_periods = wp_get_schedules();
1475
-
1476
- if( empty( $cron_activated ) )
1477
- $cron_activated = false;
1478
-
1479
- if( empty( $send_mail_cron ) )
1480
- $send_mail_cron = false;
1481
-
1482
- if( empty( $send_mail_updated ) )
1483
- $send_mail_updated = false;
1484
-
1485
- if( empty( $cron_delete_users ) )
1486
- $cron_delete_users = false;
1487
-
1488
- if( empty( $update_roles_existing_users) )
1489
- $update_roles_existing_users = false;
1490
-
1491
- if( empty( $cron_delete_users_assign_posts ) )
1492
- $cron_delete_users_assign_posts = '';
1493
-
1494
- if( empty( $path_to_file ) )
1495
- $path_to_file = dirname( __FILE__ ) . '/test.csv';
1496
-
1497
- if( empty( $period ) )
1498
- $period = 'hourly';
1499
-
1500
- if( empty( $move_file_cron ) )
1501
- $move_file_cron = false;
1502
-
1503
- if( empty( $path_to_move ) )
1504
- $path_to_move = dirname( __FILE__ ) . '/move.csv';
1505
-
1506
- if( empty( $path_to_move_auto_rename ) )
1507
- $path_to_move_auto_rename = false;
1508
-
1509
- if( empty( $log ) )
1510
- $log = "No tasks done yet.";
1511
-
1512
- if( empty( $allow_multiple_accounts ) )
1513
- $allow_multiple_accounts = "not_allowed";
1514
- ?>
1515
- <h3><?php _e( "Execute an import of users periodically", 'import-users-from-csv-with-meta' ); ?></h3>
1516
-
1517
- <form method="POST" enctype="multipart/form-data" action="" accept-charset="utf-8">
1518
- <table class="form-table">
1519
- <tbody>
1520
- <tr class="form-field">
1521
- <th scope="row"><label for="path_to_file"><?php _e( "Path of file that are going to be imported", 'import-users-from-csv-with-meta' ); ?></label></th>
1522
- <td>
1523
- <input placeholder="<?php _e('Insert complete path to the file', 'import-users-from-csv-with-meta' ) ?>" type="text" name="path_to_file" id="path_to_file" value="<?php echo $path_to_file; ?>" style="width:70%;" />
1524
- <p class="description"><?php _e( 'You have to introduce the path to file, i.e.:', 'import-users-from-csv-with-meta' ); ?> <?php $upload_dir = wp_upload_dir(); echo $upload_dir["path"]; ?>/test.csv</p>
1525
- </td>
1526
- </tr>
1527
- <tr class="form-field form-required">
1528
- <th scope="row"><label for="period"><?php _e( 'Period', 'import-users-from-csv-with-meta' ); ?></label></th>
1529
- <td>
1530
- <select id="period" name="period">
1531
- <?php foreach( $loaded_periods as $key => $value ): ?>
1532
- <option <?php if( $period == $key ) echo "selected='selected'"; ?> value="<?php echo $key; ?>"><?php echo $value['display']; ?></option>
1533
- <?php endforeach; ?>
1534
- </select>
1535
- <p class="description"><?php _e( 'How often the event should reoccur?', 'import-users-from-csv-with-meta' ); ?></p>
1536
- </td>
1537
- </tr>
1538
- <tr class="form-field form-required">
1539
- <th scope="row"><label for="cron-activated"><?php _e( 'Activate periodical import?', 'import-users-from-csv-with-meta' ); ?></label></th>
1540
- <td>
1541
- <input type="checkbox" name="cron-activated" value="yes" <?php if( $cron_activated == true ) echo "checked='checked'"; ?>/>
1542
- </td>
1543
- </tr>
1544
- <tr class="form-field form-required">
1545
- <th scope="row"><label for="send-mail-cron"><?php _e( 'Send mail when using periodical import?', 'import-users-from-csv-with-meta' ); ?></label></th>
1546
- <td>
1547
- <input type="checkbox" name="send-mail-cron" value="yes" <?php if( $send_mail_cron == true ) echo "checked='checked'"; ?>/>
1548
- </td>
1549
- </tr>
1550
- <tr class="form-field form-required">
1551
- <th scope="row"><label for="send-mail-updated"><?php _e( 'Send mail also to users that are being updated?', 'import-users-from-csv-with-meta' ); ?></label></th>
1552
- <td>
1553
- <input type="checkbox" name="send-mail-updated" value="yes" <?php if( $send_mail_updated == true ) echo "checked='checked'"; ?>/>
1554
- </td>
1555
- </tr>
1556
-
1557
- <?php if( is_plugin_active( 'allow-multiple-accounts/allow-multiple-accounts.php' ) ): ?>
1558
-
1559
- <tr class="form-field form-required">
1560
- <th scope="row"><label><?php _e( 'Repeated email in different users?', 'import-users-from-csv-with-meta' ); ?></label></th>
1561
- <td>
1562
- <input type="checkbox" name="allow_multiple_accounts" value="yes" <?php if( $allow_multiple_accounts == "allowed" ) echo "checked='checked'"; ?>/>
1563
- <p class="description"><strong>(<?php _e( 'Only for', 'import-users-from-csv-with-meta' ); ?> <a href="https://wordpress.org/plugins/allow-multiple-accounts/"><?php _e( 'Allow Multiple Accounts', 'import-users-from-csv-with-meta' ); ?></a> <?php _e( 'users', 'import-users-from-csv-with-meta'); ?>)</strong>. <?php _e('Allow multiple user accounts to be created having the same email address.','import-users-from-csv-with-meta' ); ?></p>
1564
- </td>
1565
- </tr>
1566
-
1567
- <?php endif; ?>
1568
-
1569
- <tr class="form-field form-required">
1570
- <th scope="row"><label for="cron-delete-users"><?php _e( 'Delete users that are not present in the CSV?', 'import-users-from-csv-with-meta' ); ?></label></th>
1571
- <td>
1572
- <div style="float:left;">
1573
- <input type="checkbox" name="cron-delete-users" value="yes" <?php if( $cron_delete_users == true ) echo "checked='checked'"; ?>/>
1574
- </div>
1575
- <div style="margin-left:25px;">
1576
- <select id="cron-delete-users-assign-posts" name="cron-delete-users-assign-posts">
1577
- <?php
1578
- if( $cron_delete_users_assign_posts == '' )
1579
- echo "<option selected='selected' value=''>" . __( 'Delete posts of deled users without assing to any user', 'import-users-from-csv-with-meta' ) . "</option>";
1580
- else
1581
- echo "<option value=''>" . __( 'Delete posts of deled users without assing to any user', 'import-users-from-csv-with-meta' ) . "</option>";
1582
-
1583
- $blogusers = get_users();
1584
-
1585
- foreach ( $blogusers as $bloguser ) {
1586
- if( $bloguser->ID == $cron_delete_users_assign_posts )
1587
- echo "<option selected='selected' value='{$bloguser->ID}'>{$bloguser->display_name}</option>";
1588
- else
1589
- echo "<option value='{$bloguser->ID}'>{$bloguser->display_name}</option>";
1590
- }
1591
- ?>
1592
- </select>
1593
- <p class="description"><?php _e( 'After delete users, we can choose if we want to assign their posts to another user. Please do not delete them or posts will be deleted.', 'import-users-from-csv-with-meta' ); ?></p>
1594
- </div>
1595
- </td>
1596
- </tr>
1597
- <tr class="form-field form-required">
1598
- <th scope="row"><label for="role"><?php _e( 'Role', 'import-users-from-csv-with-meta' ); ?></label></th>
1599
- <td>
1600
- <select id="role" name="role">
1601
- <?php
1602
- if( $role == '' )
1603
- echo "<option selected='selected' value=''>" . __( 'Disable role assignement in cron import', 'import-users-from-csv-with-meta' ) . "</option>";
1604
- else
1605
- echo "<option value=''>" . __( 'Disable role assignement in cron import', 'import-users-from-csv-with-meta' ) . "</option>";
1606
-
1607
- $list_roles = acui_get_editable_roles();
1608
- foreach ($list_roles as $key => $value) {
1609
- if($key == $role)
1610
- echo "<option selected='selected' value='$key'>$value</option>";
1611
- else
1612
- echo "<option value='$key'>$value</option>";
1613
- }
1614
- ?>
1615
- </select>
1616
- <p class="description"><?php _e( 'Which role would be used to import users?', 'import-users-from-csv-with-meta' ); ?></p>
1617
- </td>
1618
- </tr>
1619
- <tr class="form-field form-required">
1620
- <th scope="row"><label for="update-roles-existing-users"><?php _e( 'Update roles for existing users?', 'import-users-from-csv-with-meta' ); ?></label></th>
1621
- <td>
1622
- <input type="checkbox" name="update-roles-existing-users" value="yes" <?php if( $update_roles_existing_users == 'yes' ) echo "checked='checked'"; ?>/>
1623
- </td>
1624
- </tr>
1625
-
1626
- <tr class="form-field form-required">
1627
- <th scope="row"><label for="move-file-cron"><?php _e( 'Move file after import?', 'import-users-from-csv-with-meta' ); ?></label></th>
1628
- <td>
1629
- <div style="float:left;">
1630
- <input type="checkbox" name="move-file-cron" value="yes" <?php if( $move_file_cron == true ) echo "checked='checked'"; ?>/>
1631
- </div>
1632
-
1633
- <div class="move-file-cron-cell" style="margin-left:25px;">
1634
- <input placeholder="<?php _e( 'Insert complete path to the file', 'import-users-from-csv-with-meta'); ?>" type="text" name="path_to_move" id="path_to_move" value="<?php echo $path_to_move; ?>" style="width:70%;" />
1635
- <p class="description"><?php _e( 'You have to introduce the path to file, i.e.:', 'import-users-from-csv-with-meta'); ?> <?php $upload_dir = wp_upload_dir(); echo $upload_dir["path"]; ?>/move.csv</p>
1636
- </div>
1637
- </td>
1638
- </tr>
1639
- <tr class="form-field form-required move-file-cron-cell">
1640
- <th scope="row"><label for="move-file-cron"><?php _e( 'Auto rename after move?', 'import-users-from-csv-with-meta' ); ?></label></th>
1641
- <td>
1642
- <div style="float:left;">
1643
- <input type="checkbox" name="path_to_move_auto_rename" value="yes" <?php if( $path_to_move_auto_rename == true ) echo "checked='checked'"; ?>/>
1644
- </div>
1645
-
1646
- <div style="margin-left:25px;">
1647
- <p class="description"><?php _e( 'Your file will be renamed after moved, so you will not lost any version of it. The way to rename will be append the time stamp using this date format: YmdHis.', 'import-users-from-csv-with-meta'); ?></p>
1648
- </div>
1649
- </td>
1650
- </tr>
1651
- <tr class="form-field form-required">
1652
- <th scope="row"><label for="log"><?php _e( 'Last actions of schedule task', 'import-users-from-csv-with-meta' ); ?></label></th>
1653
- <td>
1654
- <pre><?php echo $log; ?></pre>
1655
- </td>
1656
- </tr>
1657
- </tbody>
1658
- </table>
1659
- <input class="button-primary" type="submit" value="<?php _e( 'Save schedule options', 'import-users-from-csv-with-meta'); ?>"/>
1660
- </form>
1661
-
1662
- <script>
1663
- jQuery( document ).ready( function( $ ){
1664
- $( "[name='cron-delete-users']" ).change(function() {
1665
- if( $(this).is( ":checked" ) ) {
1666
- var returnVal = confirm("<?php _e( 'Are you sure to delete all users that are not present in the CSV? This action cannot be undone.', 'import-users-from-csv-with-meta' ); ?>");
1667
- $(this).attr("checked", returnVal);
1668
-
1669
- if( returnVal )
1670
- $( '#cron-delete-users-assign-posts' ).show();
1671
- }
1672
- else{
1673
- $( '#cron-delete-users-assign-posts' ).hide();
1674
- }
1675
- });
1676
-
1677
- $( "[name='move-file-cron']" ).change(function() {
1678
- if( $(this).is( ":checked" ) ){
1679
- $( '.move-file-cron-cell' ).show();
1680
- }
1681
- else{
1682
- $( '.move-file-cron-cell' ).hide();
1683
- }
1684
- });
1685
-
1686
- <?php if( $cron_delete_users == '' ): ?>
1687
- $( '#cron-delete-users-assign-posts' ).hide();
1688
- <?php endif; ?>
1689
-
1690
- <?php if( !$move_file_cron ): ?>
1691
- $( '.move-file-cron-cell' ).hide();
1692
- <?php endif; ?>
1693
- });
1694
- </script>
1695
- <?php break; ?>
1696
-
1697
- <?php case 'donate': ?>
1698
-
1699
- <div class="postbox">
1700
- <h3 class="hndle"><span>&nbsp;<?php _e( 'Do you like it?', 'import-users-from-csv-with-meta' ); ?></span></h3>
1701
-
1702
- <div class="inside" style="display: block;">
1703
- <img src="<?php echo $url_plugin; ?>icon_coffee.png" alt="<?php _e( 'buy me a coffee', 'import-users-from-csv-with-meta' ); ?>" style=" margin: 5px; float:left;">
1704
- <p><?php _e( 'Hi! we are', 'import-users-from-csv-with-meta'); ?> <a href="https://twitter.com/fjcarazo" target="_blank" title="Javier Carazo">Javier Carazo</a> <?php _e( 'and all the team of', 'import-users-from-csv-with-meta' ); ?> <a href="http://codection.com">Codection</a>, <?php _e("developers of this plugin.", 'import-users-from-csv-with-meta' ); ?></p>
1705
- <p><?php _e( 'We have been spending many hours to develop this plugin and answering questions in the forum to give you the best support. <br>If you like and use this plugin, you can <strong>buy us a cup of coffee</strong>.', 'import-users-from-csv-with-meta' ); ?></p>
1706
- <form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
1707
- <input type="hidden" name="cmd" value="_s-xclick">
1708
- <input type="hidden" name="hosted_button_id" value="QPYVWKJG4HDGG">
1709
- <input type="image" src="https://www.paypalobjects.com/en_GB/i/btn/btn_donate_LG.gif" border="0" name="submit" alt="<?php _e('PayPal – The safer, easier way to pay online.', 'import-users-from-csv-with-meta' ); ?>">
1710
- <img alt="" border="0" src="https://www.paypalobjects.com/es_ES/i/scr/pixel.gif" width="1" height="1">
1711
- </form>
1712
- <div style="clear:both;"></div>
1713
- </div>
1714
-
1715
- <h3 class="hndle"><span>&nbsp;<?php _e( 'Or if you prefer, you can also help us becoming a Patreon:', 'import-users-from-csv-with-meta' ); ?></span></h3>
1716
-
1717
- <div class="inside acui" style="display: block;">
1718
- <a class="patreon" color="primary" type="button" name="become-a-patron" data-tag="become-patron-button" href="https://www.patreon.com/bePatron?c=1741454" role="button">
1719
- <div class="oosjif-1 jFPfxp"><span>Become a patron</span></div>
1720
- </a>
1721
- </div>
1722
- </div>
1723
-
1724
- <?php break; ?>
1725
-
1726
- <?php case 'help': ?>
1727
 
1728
- <div class="postbox">
1729
- <h3 class="hndle"><span>&nbsp;<?php _e( 'Need help with WordPress or WooCommerce?', 'import-users-from-csv-with-meta' ); ?></span></h3>
 
1730
 
1731
- <div class="inside" style="display: block;">
1732
- <p><?php _e( 'Hi! we are', 'import-users-from-csv-with-meta' ); ?> <a href="https://twitter.com/fjcarazo" target="_blank" title="Javier Carazo">Javier Carazo</a><?php _e( 'and', 'import-users-from-csv-with-meta' ) ?> <a href="https://twitter.com/ahornero" target="_blank" title="Alberto Hornero">Alberto Hornero</a> <?php _e( 'from', 'import-users-from-csv-with-meta' ); ?> <a href="http://codection.com">Codection</a>, <?php _e( 'developers of this plugin.', 'import-users-from-csv-with-meta' ); ?></p>
1733
- <p><?php _e( 'We work everyday with WordPress and WooCommerce, if you need help hire us, send us a message to', 'import-users-from-csv-with-meta' ); ?> <a href="mailto:contacto@codection.com">contacto@codection.com</a>.</p>
1734
- <div style="clear:both;"></div>
1735
- </div>
1736
- </div>
1737
 
1738
- <?php break; ?>
1739
- <?php
 
1740
  }
1741
  }
110
  if( count( $data ) == 1 )
111
  $data = $data[0];
112
 
113
+ if( !is_array( $data ) ){
114
+ _e( 'CSV file seems to be bad formed. Please use LibreOffice to create and manage CSV to be sure the format is correct', 'import-users-from-csv-with-meta');
115
+ break;
116
+ }
117
+
118
  foreach ( $data as $key => $value ){
119
  $data[ $key ] = preg_replace( '/<script\b[^>]*>(.*?)<\/script>/is', '', trim( $value ) );
120
  }
583
  $headers_mail = array();
584
  $headers_mail = apply_filters( 'acui_import_email_headers', $headers_mail, $headers, $data );
585
 
586
+ $attachments = array();
587
+ $attachment_id = get_option( 'acui_mail_attachment_id' );
588
+ if( $attachment_id != 0 )
589
+ $attachments[] = get_attached_file( $attachment_id );
590
+
591
  add_filter( 'wp_mail_content_type', 'cod_set_html_content_type' );
592
 
593
  if( get_option( "acui_settings" ) == "plugin" ){
595
  add_filter( 'wp_mail_from', 'acui_mail_from' );
596
  add_filter( 'wp_mail_from_name', 'acui_mail_from_name' );
597
 
598
+ wp_mail( apply_filters( 'acui_import_email_to', $email, $headers, $data ), $subject, $body_mail, $headers_mail, $attachments );
599
 
600
  remove_filter( 'wp_mail_from', 'acui_mail_from' );
601
  remove_filter( 'wp_mail_from_name', 'acui_mail_from_name' );
661
  }
662
 
663
  function acui_options(){
664
+ global $acui_url_plugin;
665
 
666
  if ( !current_user_can('create_users') ) {
667
  wp_die( __( 'You are not allowed to see this content.', 'import-users-from-csv-with-meta' ));
706
  acui_admin_tabs('homepage');
707
 
708
  switch ( $tab ){
709
+ case 'homepage' :
710
+ ACUI_Homepage::admin_gui();
711
+ break;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
712
 
713
+ case 'frontend':
714
+ ACUI_Frotend::admin_gui();
715
+ break;
716
 
717
+ case 'columns':
718
+ ACUI_Columns::admin_gui();
719
  break;
720
 
721
  case 'doc':
722
+ ACUI_Doc::message();
723
+ break;
724
 
725
+ case 'mail-options':
726
+ ACUI_Email_Options::admin_gui();
727
+ break;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
728
 
729
+ case 'cron':
730
+ ACUI_Cron::admin_gui();
731
+ break;
732
 
733
+ case 'donate':
734
+ ACUI_Donate::message();
735
+ break;
 
 
 
736
 
737
+ case 'help':
738
+ ACUI_Help::message();
739
+ break;
740
  }
741
  }
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: http://paypal.me/codection
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.0.0
7
- Stable tag: 1.12.1
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -71,11 +71,17 @@ Plugin will automatically detect:
71
 
72
  == Changelog ==
73
 
 
 
 
 
 
 
74
  = 1.12.1 =
75
  * Filter added to avoid script inside values of each cells to prevent XSS attacks, thanks for reporting Slawek Zytko
76
 
77
  = 1.12 =
78
- * Plugin can now manage mail templates for managing mails which are sent to users
79
 
80
  = 1.11.3.17 =
81
  * Documentation improved with some notes about roles management thanks to @stephenfourie (https://wordpress.org/support/topic/user-role-always-set-as-administrator/)
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.0.0
7
+ Stable tag: 1.12.2
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
71
 
72
  == Changelog ==
73
 
74
+ = 1.12.2 =
75
+ * Extra check to avoid problems with CSV bad formed
76
+ * Plugin can now manage attachments in email sending and email templates thanks to Immersedtechnologies
77
+ * Part of the code has been rewritten using classes
78
+ * We have changed the way of detecting the delimiter (thanks to @chaskinsuk https://wordpress.org/support/topic/detect-delimiter-fails-with-serialized-data/)
79
+
80
  = 1.12.1 =
81
  * Filter added to avoid script inside values of each cells to prevent XSS attacks, thanks for reporting Slawek Zytko
82
 
83
  = 1.12 =
84
+ * Plugin can now manage email templates for managing mails which are sent to users thanks to Immersedtechnologies
85
 
86
  = 1.11.3.17 =
87
  * Documentation improved with some notes about roles management thanks to @stephenfourie (https://wordpress.org/support/topic/user-role-always-set-as-administrator/)