Import users from CSV with meta - Version 1.12

Version Description

  • Plugin can now manage mail templates for managing mails which are sent to users thanks to Joel Frankwick for the support and testing
Download this release

Release Info

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

Code changes from version 1.11.3.17 to 1.12

email-templates.php ADDED
@@ -0,0 +1,95 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
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' );
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.11.3.17
7
  Author: codection
8
  Author URI: https://codection.com
9
  License: GPL2
@@ -24,6 +24,7 @@ include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
24
 
25
  require_once( "smtp.php" );
26
  require_once( "email-repeated.php" );
 
27
 
28
  if( is_plugin_active( 'buddypress/bp-loader.php' ) ){
29
  if ( defined( 'BP_VERSION' ) )
@@ -82,6 +83,8 @@ function acui_activate(){
82
 
83
  add_option( "acui_mail_subject", __('Welcome to', 'import-users-from-csv-with-meta') . ' ' . get_bloginfo("name"), '', false );
84
  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 );
 
 
85
 
86
  add_option( "acui_cron_activated", false );
87
  add_option( "acui_cron_send_mail", false );
@@ -127,6 +130,8 @@ function acui_delete_options(){
127
 
128
  delete_option( "acui_mail_subject" );
129
  delete_option( "acui_mail_body" );
 
 
130
 
131
  delete_option( "acui_cron_activated" );
132
  delete_option( "acui_cron_send_mail" );
@@ -424,6 +429,15 @@ function acui_save_mail_template( $form_data ){
424
  update_option( "acui_automattic_wordpress_email", stripslashes( $form_data["automattic_wordpress_email"] ) );
425
  update_option( "acui_mail_body", stripslashes( $form_data["body_mail"] ) );
426
  update_option( "acui_mail_subject", stripslashes( $form_data["subject_mail"] ) );
 
 
 
 
 
 
 
 
 
427
  ?>
428
  <div class="updated">
429
  <p><?php _e( 'Mail template updated correctly', 'import-users-from-csv-with-meta' )?></p>
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
7
  Author: codection
8
  Author URI: https://codection.com
9
  License: GPL2
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' ) )
83
 
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 );
90
  add_option( "acui_cron_send_mail", false );
130
 
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" );
137
  delete_option( "acui_cron_send_mail" );
429
  update_option( "acui_automattic_wordpress_email", stripslashes( $form_data["automattic_wordpress_email"] ) );
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(
436
+ 'ID' => $form_data["template_id"],
437
+ 'post_title' => $form_data["subject_mail"],
438
+ 'post_content' => $form_data["body_mail"],
439
+ ) );
440
+ }
441
  ?>
442
  <div class="updated">
443
  <p><?php _e( 'Mail template updated correctly', 'import-users-from-csv-with-meta' )?></p>
importer.php CHANGED
@@ -1347,6 +1347,8 @@ function acui_options(){
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
  $automattic_wordpress_email = get_option( "acui_automattic_wordpress_email" );
1351
  ?>
1352
  <form method="POST" enctype="multipart/form-data" action="" accept-charset="utf-8">
@@ -1373,30 +1375,78 @@ function acui_options(){
1373
  </fieldset>
1374
  </td>
1375
  </tr>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1376
  </tbody>
1377
- </table>
 
 
 
 
 
 
1378
 
1379
  <h3><?php _e( 'Customize the email that can be sent when importing users', 'import-users-from-csv-with-meta' ); ?></h3>
1380
-
1381
  <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>
1382
- <?php wp_editor( $body_mail , 'body_mail'); ?>
 
1383
 
1384
  <br/>
1385
- <input class="button-primary" type="submit" value="Save mail template"/>
1386
 
1387
- <p>You can use:</p>
1388
- <ul style="list-style-type:disc; margin-left:2em;">
1389
- <li>**username** = <?php _e( 'username to login', 'import-users-from-csv-with-meta' ); ?></li>
1390
- <li>**password** = <?php _e( 'user password', 'import-users-from-csv-with-meta' ); ?></li>
1391
- <li>**loginurl** = <?php _e( 'current site login url', 'import-users-from-csv-with-meta' ); ?></li>
1392
- <li>**lostpasswordurl** = <?php _e( 'lost password url', 'import-users-from-csv-with-meta' ); ?></li>
1393
- <li>**passwordreseturl** = <?php _e( 'password reset url', 'import-users-from-csv-with-meta' ); ?></li>
1394
- <li>**email** = <?php _e( 'user email', 'import-users-from-csv-with-meta' ); ?></li>
1395
- <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>
1396
- </ul>
1397
 
1398
  </form>
1399
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1400
  <?php break; ?>
1401
 
1402
  <?php case 'smtp-settings': ?>
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">
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': ?>
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.11.3.17
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -71,6 +71,9 @@ Plugin will automatically detect:
71
 
72
  == Changelog ==
73
 
 
 
 
74
  = 1.11.3.17 =
75
  * Documentation improved with some notes about roles management thanks to @stephenfourie (https://wordpress.org/support/topic/user-role-always-set-as-administrator/)
76
 
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
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 =
75
+ * Plugin can now manage mail templates for managing mails which are sent to users thanks to Joel Frankwick for the support and testing
76
+
77
  = 1.11.3.17 =
78
  * Documentation improved with some notes about roles management thanks to @stephenfourie (https://wordpress.org/support/topic/user-role-always-set-as-administrator/)
79