strangerstudios / pmpro-courses

Create courses with lessons and manage member access access natively in Paid Memberships Pro. Also integrates membership with third party LMS plugins like LifterLMS, LearnDash, Tutor LMS, and Sensei LMS.
https://www.paidmembershipspro.com/add-ons/pmpro-courses-lms-integration/
3 stars 12 forks source link

Issue with automatic enrollment and unenrollment and MMPU. #55

Closed andrewlimaza closed 1 year ago

andrewlimaza commented 1 year ago

Describe the bug There are various inconsistencies with MMPU and auto enrollment and unenrollment. Specifically around level ID's and order of checkout as well as cancellations.

I've been testing this with LearnDash, but I assume it will affect all modules that leverage this code.

I'm going to merge these two issues into one issue (as they are closely related - let me know if you need me to break these issues into separate issues rather).

Summary of issues

  1. There is an issue when you purchase a membership level with a higher ID, then signup for a lower level ID. This causes you to lose active enrollments even though you did not cancel your first level purchased.
  2. When cancelling a level, but there are still other active levels on your profile (MMPU) it does not unenroll automatically for the level cancelled. It only unenrolls you from the last and only level on your account before having no levels left.

Reference to code: https://github.com/strangerstudios/pmpro-courses/blob/dev/includes/modules/learndash.php#L247 (pmpro_after_all_membership_level_changes)

To Reproduce

Be sure to create courses that do not have multiple levels assigned for this test. I.e. Course A = Level 1, Course B = Level 2 (so we can clearly test the enrollment/unenrollment course ID's).

ISSUE 1 (Purchasing different levels = loses enrollment)

  1. Purchase level ID 2 and see you are enrolled to Course B (for example)
  2. Navigate to purchase level ID 1 - make sure you do not cancel level 2. You will be removed from Course B and given access to Course A.

If you do the inverse of this (i.e. Purchase level 2 and then level 3 = all fine).

ISSUE 2 (Cancelling = no unenrollment)

  1. Be sure to purchase level 1 and then level 2 to be assigned to multiple courses. Check that you are enrolled correctly.
  2. Cancel level 2, see that you are not unenrolled from Course B (or courses assigned to level 2)
  3. With only level 1 left, cancel level 1. See that you are unenrolled from Course A (or courses assigned to level 1).

Only the last level cancelled = unenrolled. I have not tested this by cancelling multiple level ID's.

Isolating the problem (mark completed items with an [x]):

WordPress Environment

``` Please share non-sensitive information about your hosting environment such as WordPress version, PHP version, Paid Memberships Pro and any related plugins versions. ```