strangerstudios / pmpro-cancel-on-next-payment-date

Change membership cancellation in Paid Memberships Pro to set expiration for next payment date instead of cancelling immediately.
https://www.paidmembershipspro.com/add-ons/cancel-on-next-payment-date
8 stars 8 forks source link

Membership canceled when canceling all memberships #27

Open michaelbeil opened 2 years ago

michaelbeil commented 2 years ago

Describe the bug When you click Cancel All Memberships on the Membership Cancel page, the member is completely canceled. A member saw this, and then their membership was no longer active as reported in ticket 350073 (moderators only).

To Reproduce Steps to reproduce the behavior:

  1. Go to the Membership Cancel page
  2. Click on 'Cancel All Memberships', membership is now inactive
  3. Go to a restricted article
  4. The member will no longer have access

Screenshots imageimage image Screen video

Expected behavior I expected the membership to stay active.

Isolating the problem:

WordPress Environment

``` Paid Memberships Pro 2.6.5, Cancel on Next Payment Date .4, Twenty Twenty-One 1.4, WordPress 5.8.2, and PHP 7.4.1 ```
mircobabini commented 2 years ago

We should check in core:

Every time the $cancel_level is set, CONPD recognize it as "cancel the automatic renewal"; when the $cancel_level is not set, CONPD can't do its job and the membership is just cancelled (deactivated).

ideadude commented 2 years ago

Yes, Mirco found the problem.

One solution would be to detect when 'all' is passed and swap that out for a list of level ids. This would ensure the levels are looped through and cancelled one by one.

This would fix the issue with CONP but also change the behavior to sending multiple emails... one per level. This might be preferred. The "your membership will expire on..." value CONP swaps in is going to be for one level only if you are cancelling multiple levels.

In the meantime, here is a gist that does this: https://gist.github.com/ideadude/b4237c338e47161ca726a5fcf569465a

We would probably just want to update the preheader/cancel.php file to do this swap if we updated core to do this.

It's also just a good idea in general to go around swapping out calls to pmpro_changeMembershipLevel(0, ...) to pmpro_cancelMembershipLevel() where applicable. In add ons in particular, we wanted to wait a while for people to update PMPro core, but we've waited long enough.

MaryOJob commented 2 years ago

Similar issue, please: ##416089

ipokkel commented 1 year ago

Similar issue: 462744

michaelbeil commented 1 year ago

Reported by a customer (ticket ID 477764):

on my side I could not reproduce the bug, that is to say that even if I let activate all the plugins it worked i.e. when I connected and I canceled my membership it worked fine and an expiration date was created based on the next payment date. So in fact everything was working very well BUT finally I found how to reproduce the bug and that even if all the plugins are deactivated. When I go to the “membership cancellation” menu there are two buttons, the first is called “cancel” and is located on the same line as the description of my subscription and the second button is located below the list subscriptions and is entitled “cancel all my memberships”. And that’s where the bug is depending on which button I’m using. If I click on “cancelled” all is working fine, the expiration for later is created, but if I click on “cancel all my memberships” then in this case it does not work and the subscription expires immediately.

Sent the gist.