• Resolved stevefwdedu

    (@stevefwdedu)


    We phased out a membership and transferred users who were in that membership to a different one. It was a large amount of users so it was necessary to do the transfer through a script.

    Some users were already in the destination membership, so in my script I simply unenrolled those users from the phased out membership and took no further action. However, there was course overlap between these two memberships and it turns out that the unenroll action unenrolled those users from overlapping courses even though they should have maintained access through their other membership.

    To me this was unexpected logic. I’ve already developed the script to toggle the membership off and on to get their access back. Just reporting for awareness. Here’s the core of the script:

    $old_membership_id = 123;

    $new_membership_id = 456;

    // get students that are enrolled in the old membership

    $old_membership = new LLMS_Membership($old_membership_id);

    $students = $old_membership->get_students('enrolled', 9999);

    foreach ($students as $student_id) {

    // Unenroll from the old membership

    llms_unenroll_student($student_id, $old_membership_id);

    if (!llms_is_user_enrolled($student_id, $new_membership_id)) {

    // Enroll in the new membership

    llms_enroll_student($student_id, $new_membership_id, 'old-membership-migration');

    }

    }
    • This topic was modified 3 months, 3 weeks ago by stevefwdedu.

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Brian Hogg

    (@brianhogg)

    Thanks @stevefwdedu for the information!

    We do have a related open issue and I’ve added a comment with your notes:

    https://github.com/gocodebox/lifterlms/issues/1861

    I’m hoping if we are able to solve the problem of llms_unenroll_student removing students from Courses they should still have access to via another membership, it’ll also solve the problem via actions like cancelling an order for a membership as per this ticket.

    Feel free to follow the issue on Github and we’ll try to make a note here when a fix has been made available.

    Plugin Author Brian Hogg

    (@brianhogg)

    Hi @stevefwdedu,

    Version 7.7 included a fix for the functionality of llms_unenroll_student so will mark this as resolved. Let us know if you have any other questions by starting a new topic. Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.