Import users from CSV with meta - Version 1.12.3

Version Description

  • Integration with Paid Membership Pro improved thanks to @joneiseman (https://wordpress.org/support/topic/import-paid-membership-pro-fields-not-working/#post-11110984)
Download this release

Release Info

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

Code changes from version 1.12.2.3 to 1.12.3

addons/acui-pmpro.php CHANGED
@@ -82,10 +82,12 @@ function acui_pmpro_post_import_single_user( $headers, $row, $user_id ){
82
  if( !empty( $membership_discount_code ) && empty( $membership_code_id ) )
83
  $membership_code_id = $wpdb->get_var( "SELECT id FROM $wpdb->pmpro_discount_codes WHERE `code` = '" . esc_sql( $membership_discount_code ) . "' LIMIT 1" );
84
 
85
- if( !empty( $membership_id ) && empty( $membership_code_id ) ){
86
- pmpro_changeMembershipLevel( $membership_id, $user_id );
87
- }
88
- elseif( !empty( $membership_code_id ) ){
 
 
89
  $custom_level = array(
90
  'user_id' => $user_id,
91
  'membership_id' => $membership_id,
@@ -104,14 +106,15 @@ function acui_pmpro_post_import_single_user( $headers, $row, $user_id ){
104
 
105
  pmpro_changeMembershipLevel( $custom_level, $user_id );
106
 
 
107
  if( $membership_status === "inactive" || ( !empty( $membership_enddate ) && $membership_enddate !== "NULL" && strtotime( $membership_enddate, current_time('timestamp') ) < current_time('timestamp') ) ){
108
- $sqlQuery = "UPDATE $wpdb->pmpro_memberships_users SET status = 'inactive' WHERE user_id = '" . $user_id . "' AND membership_id = '" . $membership_id . "'";
109
  $wpdb->query( $sqlQuery );
110
  $membership_in_the_past = true;
111
  }
112
 
113
- if( $membership_status === "active" && ( empty( $membership_enddate ) || $membership_enddate === "NULL" || strtotime( $membership_enddate, current_time( 'timestamp' ) ) >= current_time( 'timestamp' ) ) ){
114
- $sqlQuery = $wpdb->prepare( "UPDATE {$wpdb->pmpro_memberships_users} SET status = 'active' WHERE user_id = %d AND membership_id = %d", $user_id, $membership_id );
115
  $wpdb->query( $sqlQuery );
116
  }
117
  }
82
  if( !empty( $membership_discount_code ) && empty( $membership_code_id ) )
83
  $membership_code_id = $wpdb->get_var( "SELECT id FROM $wpdb->pmpro_discount_codes WHERE `code` = '" . esc_sql( $membership_discount_code ) . "' LIMIT 1" );
84
 
85
+ if( !empty( $membership_discount_code ) && empty( $membership_code_id ) )
86
+ $membership_code_id = $wpdb->get_var("SELECT id FROM $wpdb->pmpro_discount_codes WHERE `code` = '" . esc_sql($membership_discount_code) . "' LIMIT 1");
87
+
88
+ //change membership level
89
+ if( !empty( $membership_id ) )
90
+ {
91
  $custom_level = array(
92
  'user_id' => $user_id,
93
  'membership_id' => $membership_id,
106
 
107
  pmpro_changeMembershipLevel( $custom_level, $user_id );
108
 
109
+ //if membership was in the past make it inactive
110
  if( $membership_status === "inactive" || ( !empty( $membership_enddate ) && $membership_enddate !== "NULL" && strtotime( $membership_enddate, current_time('timestamp') ) < current_time('timestamp') ) ){
111
+ $sqlQuery = "UPDATE $wpdb->pmpro_memberships_users SET status = 'inactive' WHERE user_id = '" . $user_id . "' AND membership_id = '" . $membership_id . "'";
112
  $wpdb->query( $sqlQuery );
113
  $membership_in_the_past = true;
114
  }
115
 
116
+ if( $membership_status === "active" && ( empty( $membership_enddate ) || $membership_enddate === "NULL" || strtotime( $membership_enddate, current_time('timestamp') ) >= current_time('timestamp') ) ){
117
+ $sqlQuery = $wpdb->prepare( "UPDATE {$wpdb->pmpro_memberships_users} SET status = 'active' WHERE user_id = %d AND membership_id = %d", $user_id, $membership_id );
118
  $wpdb->query( $sqlQuery );
119
  }
120
  }
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.2.3
7
  Author: codection
8
  Author URI: https://codection.com
9
  License: GPL2
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.3
7
  Author: codection
8
  Author URI: https://codection.com
9
  License: GPL2
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.3
7
- Stable tag: 1.12.2.3
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -74,6 +74,9 @@ Plugin will automatically detect:
74
 
75
  == Changelog ==
76
 
 
 
 
77
  = 1.12.2.3 =
78
  * Readme updated
79
 
@@ -568,7 +571,6 @@ Plugin will automatically detect:
568
  = 1.1.7 =
569
  * Fixed problems with \n, \r and \n\r inside CSV fields. Thanks to Ted Stresen-Reuter for his help. We have changed our way to parse CSV files, now we use SplFileObject and we can solve this problem.
570
 
571
- =======
572
  = 1.2 =
573
  * From this version, plugin can both insert new users and update new ones. Thanks to Nick Gallop from Weston Graphics.
574
 
@@ -578,7 +580,6 @@ Plugin will automatically detect:
578
  = 1.1.7 =
579
  * Fixed problems with \n, \r and \n\r inside CSV fields. Thanks to Ted Stresen-Reuter for his help. We have changed our way to parse CSV files, now we use SplFileObject and we can solve this problem.
580
 
581
- >>>>>>> .r1121403
582
  = 1.1.6 =
583
  * You can import now user_registered but always in the correct format Y-m-d H:i:s
584
 
@@ -684,7 +685,7 @@ You can get:
684
  * Premium support [writing directly to contacto@codection.com](mailto:contacto@codection.com).
685
 
686
  = Customizations, addons, develops... =
687
- [Write u directly to contacto@codection.com](mailto:contacto@codection.com).
688
 
689
  == Installation ==
690
 
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.3
7
+ Stable tag: 1.12.3
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
74
 
75
  == Changelog ==
76
 
77
+ = 1.12.3 =
78
+ * Integration with Paid Membership Pro improved thanks to @joneiseman (https://wordpress.org/support/topic/import-paid-membership-pro-fields-not-working/#post-11110984)
79
+
80
  = 1.12.2.3 =
81
  * Readme updated
82
 
571
  = 1.1.7 =
572
  * Fixed problems with \n, \r and \n\r inside CSV fields. Thanks to Ted Stresen-Reuter for his help. We have changed our way to parse CSV files, now we use SplFileObject and we can solve this problem.
573
 
 
574
  = 1.2 =
575
  * From this version, plugin can both insert new users and update new ones. Thanks to Nick Gallop from Weston Graphics.
576
 
580
  = 1.1.7 =
581
  * Fixed problems with \n, \r and \n\r inside CSV fields. Thanks to Ted Stresen-Reuter for his help. We have changed our way to parse CSV files, now we use SplFileObject and we can solve this problem.
582
 
 
583
  = 1.1.6 =
584
  * You can import now user_registered but always in the correct format Y-m-d H:i:s
585
 
685
  * Premium support [writing directly to contacto@codection.com](mailto:contacto@codection.com).
686
 
687
  = Customizations, addons, develops... =
688
+ [Write us directly to contacto@codection.com](mailto:contacto@codection.com).
689
 
690
  == Installation ==
691