Paid Memberships Pro - Version 2.0.3

Version Description

  • 2019-01-11 =
  • BUG FIX: Fixed issue where code in the Stripe gateway was cancelling old subscriptions early if users renewed with a different gateway. NOTE: There was a fix for this in version 2.0, but it wasn't implemented fully.
  • BUG FIX: Filtering pmpro_other_order_ids_to_cancel to make sure the current checkout's order doesn't get cancelled. This started happening in version 2.0 since we started setting the user_id on orders for existing users before the checkout was fully processed. This fix along with the one above and others will fix cases where users were being cancelled immediately after checkout.
  • BUG FIX: Fixed warning on edit levels page by defaulting $confirmation_in_email to 0.
Download this release

Release Info

Developer strangerstudios
Plugin Icon 128x128 Paid Memberships Pro
Version 2.0.3
Comparing to
See all releases

Code changes from version 2.0.2 to 2.0.3

CHANGELOG.txt CHANGED
@@ -1,5 +1,10 @@
1
  == Changelog ==
2
 
 
 
 
 
 
3
  = 2.0.2 - 2019-01-10 =
4
  * BUG FIX: Fixed issues when using non-US currencies. Using the pmpro_round_price function in a few places it was needed. Prepared for a later update that will increase the number of decimals on certain columns in the DB to 8 to support currencies like Bitcoin, but shelving the actual DB update for version 2.1.
5
  * BUG FIX: Fixed issue where existing users who checked out could run into problems. Added a getMembershipLevelAtCheckout method to the MemberOrder class and using that during checkout. The getMembershipLevel method would see the user_id property of the order (added to orders at checkout in version 2.0) and lookup the level data from the pmpro_memberships_users table instead of using the pmpro_level global. Then gateways like PayPal Express (but others also) would use the wrong data when making calls to pmpro_isLevelRecurring/etc.
1
  == Changelog ==
2
 
3
+ = 2.0.3 - 2019-01-11 =
4
+ * BUG FIX: Fixed issue where code in the Stripe gateway was cancelling old subscriptions early if users renewed with a different gateway. NOTE: There was a fix for this in version 2.0, but it wasn't implemented fully.
5
+ * BUG FIX: Filtering pmpro_other_order_ids_to_cancel to make sure the current checkout's order doesn't get cancelled. This started happening in version 2.0 since we started setting the user_id on orders for existing users before the checkout was fully processed. This fix along with the one above and others will fix cases where users were being cancelled immediately after checkout.
6
+ * BUG FIX: Fixed warning on edit levels page by defaulting $confirmation_in_email to 0.
7
+
8
  = 2.0.2 - 2019-01-10 =
9
  * BUG FIX: Fixed issues when using non-US currencies. Using the pmpro_round_price function in a few places it was needed. Prepared for a later update that will increase the number of decimals on certain columns in the DB to 8 to support currencies like Bitcoin, but shelving the actual DB update for version 2.1.
10
  * BUG FIX: Fixed issue where existing users who checked out could run into problems. Added a getMembershipLevelAtCheckout method to the MemberOrder class and using that during checkout. The getMembershipLevel method would see the user_id property of the order (added to orders at checkout in version 2.0) and lookup the level data from the pmpro_memberships_users table instead of using the pmpro_level global. Then gateways like PayPal Express (but others also) would use the wrong data when making calls to pmpro_isLevelRecurring/etc.
adminpages/membershiplevels.php CHANGED
@@ -331,6 +331,8 @@
331
  // grab the meta for the given level...
332
  if ( ! empty( $temp_id ) ) {
333
  $confirmation_in_email = get_pmpro_membership_level_meta( $temp_id, 'confirmation_in_email', true );
 
 
334
  }
335
 
336
  ?>
331
  // grab the meta for the given level...
332
  if ( ! empty( $temp_id ) ) {
333
  $confirmation_in_email = get_pmpro_membership_level_meta( $temp_id, 'confirmation_in_email', true );
334
+ } else {
335
+ $confirmation_in_email = 0;
336
  }
337
 
338
  ?>
classes/gateways/class.pmprogateway_stripe.php CHANGED
@@ -1038,9 +1038,16 @@
1038
  static function pmpro_checkout_before_processing() {
1039
  global $wpdb, $current_user;
1040
 
1041
- //we're only worried about cases where the user is logged in
1042
- if(!is_user_logged_in())
1043
- return;
 
 
 
 
 
 
 
1044
 
1045
  //check the $pmpro_cancel_previous_subscriptions filter
1046
  //this is used in add ons like Gift Memberships to stop PMPro from cancelling old memberships
1038
  static function pmpro_checkout_before_processing() {
1039
  global $wpdb, $current_user;
1040
 
1041
+ // we're only worried about cases where the user is logged in
1042
+ if( ! is_user_logged_in() ) {
1043
+ return;
1044
+ }
1045
+
1046
+ // make sure we're checking out with Stripe
1047
+ $current_gateway = pmpro_getGateway();
1048
+ if ( $current_gateway != 'stripe' ) {
1049
+ return;
1050
+ }
1051
 
1052
  //check the $pmpro_cancel_previous_subscriptions filter
1053
  //this is used in add ons like Gift Memberships to stop PMPro from cancelling old memberships
includes/filters.php CHANGED
@@ -234,3 +234,28 @@ function pmpro_pmpro_subscribe_order_startdate_limit( $order, $gateway ) {
234
  return $order;
235
  }
236
  add_filter( 'pmpro_subscribe_order', 'pmpro_pmpro_subscribe_order_startdate_limit', 99, 2 );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
234
  return $order;
235
  }
236
  add_filter( 'pmpro_subscribe_order', 'pmpro_pmpro_subscribe_order_startdate_limit', 99, 2 );
237
+
238
+ /**
239
+ * Before changing membership at checkout,
240
+ * let's remember the order for checkout
241
+ * so we can ignore that when cancelling old orders.
242
+ */
243
+ function pmpro_set_checkout_order_before_changing_membership_levels( $user_id, $order ) {
244
+ global $pmpro_checkout_order;
245
+ $pmpro_checkout_order = $order;
246
+ }
247
+ add_action( 'pmpro_checkout_before_change_membership_level', 'pmpro_set_checkout_order_before_changing_membership_levels', 10, 2);
248
+
249
+ /**
250
+ * Ignore the checkout order when cancelling old orders.
251
+ */
252
+ function pmpro_ignore_checkout_order_when_cancelling_old_orders( $order_ids ) {
253
+ global $pmpro_checkout_order;
254
+
255
+ if ( ! empty( $pmpro_checkout_order ) ) {
256
+ $order_ids = array_diff( $order_ids, array( $pmpro_checkout_order->id ) );
257
+ }
258
+
259
+ return $order_ids;
260
+ }
261
+ add_filter( 'pmpro_other_order_ids_to_cancel', 'pmpro_ignore_checkout_order_when_cancelling_old_orders' );
includes/functions.php CHANGED
@@ -993,6 +993,11 @@ function pmpro_changeMembershipLevel( $level, $user_id = null, $old_level_status
993
  );
994
  }
995
 
 
 
 
 
 
996
  $other_order_ids = apply_filters( 'pmpro_other_order_ids_to_cancel', $other_order_ids );
997
 
998
  // cancel any other subscriptions they have (updates pmpro_membership_orders table)
993
  );
994
  }
995
 
996
+ /**
997
+ * Filter the other/old order ids in case we want to exclude some.
998
+ * NOTE: As of version 2.0.3, includes/filters.php has code to
999
+ * ignore the order for the current checkout.
1000
+ */
1001
  $other_order_ids = apply_filters( 'pmpro_other_order_ids_to_cancel', $other_order_ids );
1002
 
1003
  // cancel any other subscriptions they have (updates pmpro_membership_orders table)
paid-memberships-pro.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: Paid Memberships Pro
4
  * Plugin URI: https://www.paidmembershipspro.com
5
  * Description: The most complete member management and membership subscriptions plugin for WordPress.
6
- * Version: 2.0.2
7
  * Author: Stranger Studios
8
  * Author URI: https://www.strangerstudios.com
9
  * Text Domain: paid-memberships-pro
@@ -16,7 +16,7 @@
16
  */
17
 
18
  // version constant
19
- define( 'PMPRO_VERSION', '2.0.2' );
20
  define( 'PMPRO_USER_AGENT', 'Paid Memberships Pro v' . PMPRO_VERSION . '; ' . site_url() );
21
  define( 'PMPRO_MIN_PHP_VERSION', '5.6' );
22
 
3
  * Plugin Name: Paid Memberships Pro
4
  * Plugin URI: https://www.paidmembershipspro.com
5
  * Description: The most complete member management and membership subscriptions plugin for WordPress.
6
+ * Version: 2.0.3
7
  * Author: Stranger Studios
8
  * Author URI: https://www.strangerstudios.com
9
  * Text Domain: paid-memberships-pro
16
  */
17
 
18
  // version constant
19
+ define( 'PMPRO_VERSION', '2.0.3' );
20
  define( 'PMPRO_USER_AGENT', 'Paid Memberships Pro v' . PMPRO_VERSION . '; ' . site_url() );
21
  define( 'PMPRO_MIN_PHP_VERSION', '5.6' );
22
 
readme.txt CHANGED
@@ -2,8 +2,8 @@
2
  Contributors: strangerstudios
3
  Tags: membership, memberships, member, members, ecommerce, e-commerce, paypal, stripe, braintree, authorize.net, payflow, restrict access, restrict content, directory
4
  Requires at least: 4
5
- Tested up to: 5.0.2
6
- Stable tag: 2.0.2
7
 
8
  Get Paid with Paid Memberships Pro: The most complete member management and membership subscriptions plugin for your WordPress site.
9
 
@@ -129,6 +129,11 @@ Not sure? You can find out by doing a bit a research.
129
 
130
  == Changelog ==
131
 
 
 
 
 
 
132
  = 2.0.2 - 2019-01-10 =
133
  * BUG FIX: Fixed issues when using non-US currencies. Using the pmpro_round_price function in a few places it was needed. Prepared for a later update that will increase the number of decimals on certain columns in the DB to 8 to support currencies like Bitcoin, but shelving the actual DB update for version 2.1.
134
  * BUG FIX: Fixed issue where existing users who checked out could run into problems. Added a getMembershipLevelAtCheckout method to the MemberOrder class and using that during checkout. The getMembershipLevel method would see the user_id property of the order (added to orders at checkout in version 2.0) and lookup the level data from the pmpro_memberships_users table instead of using the pmpro_level global. Then gateways like PayPal Express (but others also) would use the wrong data when making calls to pmpro_isLevelRecurring/etc.
2
  Contributors: strangerstudios
3
  Tags: membership, memberships, member, members, ecommerce, e-commerce, paypal, stripe, braintree, authorize.net, payflow, restrict access, restrict content, directory
4
  Requires at least: 4
5
+ Tested up to: 5.0.3
6
+ Stable tag: 2.0.3
7
 
8
  Get Paid with Paid Memberships Pro: The most complete member management and membership subscriptions plugin for your WordPress site.
9
 
129
 
130
  == Changelog ==
131
 
132
+ = 2.0.3 - 2019-01-11 =
133
+ * BUG FIX: Fixed issue where code in the Stripe gateway was cancelling old subscriptions early if users renewed with a different gateway. NOTE: There was a fix for this in version 2.0, but it wasn't implemented fully.
134
+ * BUG FIX: Filtering pmpro_other_order_ids_to_cancel to make sure the current checkout's order doesn't get cancelled. This started happening in version 2.0 since we started setting the user_id on orders for existing users before the checkout was fully processed. This fix along with the one above and others will fix cases where users were being cancelled immediately after checkout.
135
+ * BUG FIX: Fixed warning on edit levels page by defaulting $confirmation_in_email to 0.
136
+
137
  = 2.0.2 - 2019-01-10 =
138
  * BUG FIX: Fixed issues when using non-US currencies. Using the pmpro_round_price function in a few places it was needed. Prepared for a later update that will increase the number of decimals on certain columns in the DB to 8 to support currencies like Bitcoin, but shelving the actual DB update for version 2.1.
139
  * BUG FIX: Fixed issue where existing users who checked out could run into problems. Added a getMembershipLevelAtCheckout method to the MemberOrder class and using that during checkout. The getMembershipLevel method would see the user_id property of the order (added to orders at checkout in version 2.0) and lookup the level data from the pmpro_memberships_users table instead of using the pmpro_level global. Then gateways like PayPal Express (but others also) would use the wrong data when making calls to pmpro_isLevelRecurring/etc.