Import users from CSV with meta - Version 1.16.1

Version Description

  • Multisite check and fix issues
  • Addon to include compatibility included Paid Member Subscriptions by Cozmoslabs thanks to Marian Lowe
  • Fixed with email templates not being created
Download this release

Release Info

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

Code changes from version 1.16 to 1.16.1

addons/paid-member-subscriptions.php ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if ( ! defined( 'ABSPATH' ) ) exit;
3
+
4
+ if( !is_plugin_active( 'paid-member-subscriptions/index.php' ) ){
5
+ return;
6
+ }
7
+
8
+ class ACUI_PaidMemberSubscriptions{
9
+ function __construct(){
10
+ add_filter( 'acui_restricted_fields', array( $this, 'restricted_fields' ), 10, 1 );
11
+ add_action( 'acui_documentation_after_plugins_activated', array( $this, 'documentation' ) );
12
+ add_action( 'post_acui_import_single_user', array( $this, 'assign' ), 10, 4 );
13
+ }
14
+
15
+ function get_fields(){
16
+ return array( 'subscription_plan_id', 'start_date', 'expiration_date', 'status' );
17
+ }
18
+
19
+ function restricted_fields( $acui_restricted_fields ){
20
+ return array_merge( $acui_restricted_fields, $this->get_fields() );
21
+ }
22
+
23
+ function documentation(){
24
+ ?>
25
+ <tr valign="top">
26
+ <th scope="row"><?php _e( "Paid Member Subscriptions is activated", 'import-users-from-csv-with-meta' ); ?></th>
27
+ <td><?php _e( "Plugin can create member subscriptions while this is importing. You will need to use those columns:", 'import-users-from-csv-with-meta' ); ?>
28
+ <ul style="list-style:disc outside none; margin-left:2em;">
29
+ <li><?php _e( "<strong>subscription_plan_id</strong>: you can find it in Paid Member Subscriptions, Subscriptions Plans ", 'import-users-from-csv-with-meta' ); ?></li>
30
+ <li><?php _e( "<strong>start_date <em>(optional)</em></strong>: if you leave empty, current moment will be used, format is Y-m-d H:i:s", 'import-users-from-csv-with-meta' ); ?></li>
31
+ <li><?php _e( "<strong>expiration_date (optional)</strong>: if you leave it empty, no expired date will be defined", 'import-users-from-csv-with-meta' ); ?></li>
32
+ <li><?php _e( "<strong>status <em>(optional)</em></strong>: if you do not fill it, active will be used", 'import-users-from-csv-with-meta' ); ?></li>
33
+ </ul>
34
+ </td>
35
+ </tr>
36
+ <?php
37
+ }
38
+
39
+ function assign( $headers, $row, $user_id, $role ){
40
+ if( !class_exists( 'PMS_Member_Subscription' ) )
41
+ return;
42
+
43
+ $keys = $this->get_fields();
44
+ $columns = array();
45
+
46
+ $status = 'active';
47
+ $start_date = date('Y-m-d H:i:s');
48
+
49
+ foreach ( $keys as $key ) {
50
+ $pos = array_search( $key, $headers );
51
+
52
+ if( $pos !== FALSE ){
53
+ $columns[ $key ] = $pos;
54
+ $$key = $row[ $columns[ $key ] ];
55
+ }
56
+ }
57
+
58
+ if( !isset( $subscription_plan_id ) || empty( $subscription_plan_id ) )
59
+ return;
60
+
61
+ $subscription_data = array(
62
+ 'user_id' => $user_id,
63
+ 'subscription_plan_id' => $subscription_plan_id,
64
+ 'start_date' => $start_date,
65
+ 'status' => $status,
66
+ );
67
+
68
+ if( isset( $expiration_date ) && !empty( $expiration_date ) )
69
+ $subscription_data['expiration_date'] =$expiration_date;
70
+
71
+ $subscription = new PMS_Member_Subscription();
72
+ $subscription->insert( $subscription_data );
73
+ }
74
+ }
75
+ new ACUI_PaidMemberSubscriptions();
addons/woocommerce-subscriptions.php CHANGED
@@ -1,5 +1,4 @@
1
  <?php
2
-
3
  if ( ! defined( 'ABSPATH' ) ) exit;
4
 
5
  if( !is_plugin_active( 'woocommerce-subscriptions/woocommerce-subscriptions.php' ) ){
@@ -256,6 +255,10 @@ class ACUI_WooCommerceSubscritpions{
256
  try {
257
  $wpdb->query( 'START TRANSACTION' );
258
 
 
 
 
 
259
  $subscription = wcs_create_subscription( array(
260
  'customer_id' => $user_id,
261
  'start_date' => $dates_to_update['start'],
1
  <?php
 
2
  if ( ! defined( 'ABSPATH' ) ) exit;
3
 
4
  if( !is_plugin_active( 'woocommerce-subscriptions/woocommerce-subscriptions.php' ) ){
255
  try {
256
  $wpdb->query( 'START TRANSACTION' );
257
 
258
+ if( !function_exists( 'wcs_create_subscription' ) ){
259
+ require_once( WP_PLUGIN_DIR . '/woocommerce-subscriptions/wcs-functions.php' );
260
+ }
261
+
262
  $subscription = wcs_create_subscription( array(
263
  'customer_id' => $user_id,
264
  'start_date' => $dates_to_update['start'],
classes/email-templates.php CHANGED
@@ -4,7 +4,7 @@ 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' ) );
@@ -66,7 +66,6 @@ class ACUI_Email_Template{
66
  'capability_type' => 'page',
67
  );
68
  register_post_type( 'acui_email_template', $args );
69
-
70
  }
71
 
72
  public static function email_templates_edit_form_after_editor( $post = "" ){
4
 
5
  class ACUI_Email_Template{
6
  function __construct(){
7
+ add_action( 'wp_loaded', array( $this, 'cpt_email_template' ) );
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' ) );
66
  'capability_type' => 'page',
67
  );
68
  register_post_type( 'acui_email_template', $args );
 
69
  }
70
 
71
  public static function email_templates_edit_form_after_editor( $post = "" ){
classes/multisite.php CHANGED
@@ -35,7 +35,7 @@ class ACUI_Multisite{
35
  if( $pos === FALSE )
36
  return;
37
 
38
- if( is_array( $role) )
39
  $role = reset( $role );
40
 
41
  // blogs that appears in the CSV
35
  if( $pos === FALSE )
36
  return;
37
 
38
+ if( is_array( $role ) )
39
  $role = reset( $role );
40
 
41
  // blogs that appears in the CSV
import-users-from-csv-with-meta.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Import and export users and customers
4
  Plugin URI: https://www.codection.com
5
  Description: Using this plugin you will be able to import and export users or customers choosing many options and interacting with lots of other plugins
6
- Version: 1.16
7
  Author: codection
8
  Author URI: https://codection.com
9
  License: GPL2
@@ -64,7 +64,7 @@ class ImportExportUsersCustomers{
64
  );
65
  }
66
 
67
- public function on_loaded(){
68
  include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
69
 
70
  if( is_plugin_active( 'buddypress/bp-loader.php' ) || function_exists( 'bp_is_active' ) ){
@@ -267,7 +267,7 @@ class ImportExportUsersCustomers{
267
 
268
  function acui_start(){
269
  $import_export_users_customers = new ImportExportUsersCustomers();
270
- add_action( 'wp_loaded', array( $import_export_users_customers, 'on_loaded' ) );
271
  }
272
  add_action( 'plugins_loaded', 'acui_start', 8);
273
 
3
  Plugin Name: Import and export users and customers
4
  Plugin URI: https://www.codection.com
5
  Description: Using this plugin you will be able to import and export users or customers choosing many options and interacting with lots of other plugins
6
+ Version: 1.16.1
7
  Author: codection
8
  Author URI: https://codection.com
9
  License: GPL2
64
  );
65
  }
66
 
67
+ public function on_init(){
68
  include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
69
 
70
  if( is_plugin_active( 'buddypress/bp-loader.php' ) || function_exists( 'bp_is_active' ) ){
267
 
268
  function acui_start(){
269
  $import_export_users_customers = new ImportExportUsersCustomers();
270
+ add_action( 'init', array( $import_export_users_customers, 'on_init' ) );
271
  }
272
  add_action( 'plugins_loaded', 'acui_start', 8);
273
 
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://codection.com/go/donate-import-users-from-csv-with-meta/
4
  Tags: csv, import, importer, meta data, meta, user, users, user meta, editor, profile, custom, fields, delimiter, update, insert
5
  Requires at least: 3.4
6
  Tested up to: 5.5.1
7
- Stable tag: 1.16
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -99,8 +99,14 @@ Plugin will automatically detect:
99
 
100
  == Changelog ==
101
 
 
 
 
 
 
102
  = 1.16 =
103
  * Code is being rewritten to make it easy to update
 
104
 
105
  = 1.15.9.2 =
106
  * We try to make the plugin compatible with BuddyPress related themes and plugins that uses their functions but they are not BuddyPress really
4
  Tags: csv, import, importer, meta data, meta, user, users, user meta, editor, profile, custom, fields, delimiter, update, insert
5
  Requires at least: 3.4
6
  Tested up to: 5.5.1
7
+ Stable tag: 1.16.1
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
99
 
100
  == Changelog ==
101
 
102
+ = 1.16.1 =
103
+ * Multisite check and fix issues
104
+ * Addon to include compatibility included Paid Member Subscriptions by Cozmoslabs thanks to Marian Lowe
105
+ * Fixed with email templates not being created
106
+
107
  = 1.16 =
108
  * Code is being rewritten to make it easy to update
109
+ * New filter added to override the necessary capatibily to use the plugin
110
 
111
  = 1.15.9.2 =
112
  * We try to make the plugin compatible with BuddyPress related themes and plugins that uses their functions but they are not BuddyPress really