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

Custom Role is stripped and user is set to "subscriber" role #15

Closed kimwhite closed 1 year ago

kimwhite commented 3 years ago

Describe the bug When a site uses Roles for Membership Levels or has its own custom roles assigned, the user is reset to subscriber role after canceling their membership.

To Reproduce Steps to reproduce the behavior:

  1. Install This Add On
  2. Install Roles for Membership Levels Add On
  3. Create a user who is assigned a custom role
  4. Cancel a subscription
  5. User has their membership till the next payment, but they only have the subscriber role

Expected behavior While user holds a level, they should return to the same role they had before canceling.

ideadude commented 3 years ago

One root cause for this issue is that the way the add on is programmed now, it basically cancels the users membership level and then gives the user their level back a moment later.

This toggling of the membership level causes issues with the roles plugin and with other add ons and code that hook into membership level change.

Our proposed fix is to instead skip the membership cancel and just update the enddate of the membership. We've made that change in this branch and are now testing to make sure there aren't other complications from the fix. Usually a fix like this breaks other things which we need to fix. We have already identified some issues, but expect to get through them.

https://github.com/strangerstudios/pmpro-cancel-on-next-payment-date/tree/skip-cancel

You can try running this other branch on your site. It should fix the roles issue and the other issues may not come up on your site. Or wait for the next release of the add on which will have this branch merged in along with fixes to the new issues we've found.

Rsmith-gs commented 3 years ago

Usually a fix like this breaks other things which we need to fix. We have already identified some issues, but expect to get through them.

@ideadude Thanks for the update! Do you have a timeline for when this may be deployed?

ideadude commented 3 years ago

We're actively working on completing this code and should have the update out by the end of the summer.

mircobabini commented 2 years ago

@ideadude this can be closed, isn't it?

Rsmith-gs commented 2 years ago

Hello, if this has been resolved I would love to know what update it was resolved on so I can double check that it is functioning as expected on my site. I have seen some users on my site being assigned as Subscriber or no roles at all on my site still (I'm not sure if it is related to cancelling of membership).

mircobabini commented 2 years ago

@Rsmith-gs since v0.4 we are not "cancelling and giving back the membership back", instead we are just setting an enddate. Check this changelog row:

BUG FIX/ENHANCEMENT: Uses the new pmpro_change_level filter to keep the user's level from changing ever. Their order and subsciptions are cancelled and their expiration date is set up, but the pmpro_before_change_membership_level and pmpro_after_change_membership_level will not fire. This prevents issues with other code hooked into membership level changes.

By the way consider that the issue you are facing "sometimes" might be related to:

Of course you can already do some tests on your site or, if you don't have too much pressure, just wait for the next point release. Then, glad to have your feedback here to investigate further.

ideadude commented 1 year ago

Closed the issue as it should have been fixed by some updates. If it's still happening with version 0.5+, then we need more info about your specific setup. Please reach out through our support channels.