Member having assigned multiple memberships after upgrade

A member on site upgraded a membership on site to another one and instead of being switched to it, was assigned the second one. The "Multiple Memberships" add-on is not active on site (and it wasn't at the time upgrade was done) but member has two active memberships now.

  • Paul Kevin
    • Neo

    Hey there mediastead ,

    Hope you are well today. Kindly confirm if you have the option "Speed up results" in the membership settings enabled (version 1.1.2). This will cache data for at least 12 hours and changes made will not reflect until the cache data is refreshed. If the setting is enabled, please disable it and check if the issue persists.

    Warm Regards
    Paul Kevin

  • mediastead
    • The Crimson Coder

    Hello, I'm just checking in on this issue. I gave full access to the test site admin and FTP. I haven't seen any activity on the test site, so you may have not gotten to testing yet. I realize you guys are busy. This issue is causing some problems with my client, and his customers. I was hoping to resolve it soon.

    Thanks so much. I look forward to hearing from you!

  • Paul Kevin
    • Neo

    Hey there mediastead ,

    hope you are well today. Apologies for the late response on this, I will check who got the credentials you sent. In the meantime could you try add this in your themes functions.php file

    add_action( 'ms_invoice_paid', function( $invoice, $subscription ){
    
    	$member = $subscription->get_member();
    	$cur_membership = $subscription->get_membership();
    
    	$all_member_memberships = $member->get_membership_ids();
    
    	foreach( $all_member_memberships as $member_membership_id ){
    
    		if( $member_membership_id == $cur_membership->id ){
    			continue;
    		}
    
    		$member->cancel_membership( $member_membership_id );
    		$member->save();
    
    	}
    
    }, 10, 2 );

    The issue seems when an invoice is paid for a new membership, the old memberships do not get removed from the subscription.

    Warm Regards
    Paul Kevin

  • mediastead
    • The Crimson Coder

    Paul Kevin,

    I updated Membership, and tried to upgrade a test user from Free to Premium, but the update did not fix the issue. The test user has two memberships, and he is only supposed to have one.

    I liked your idea to have a hook that updated the memberships ... the snippet you gave me didn't work, but it seems promising. Perhaps we can try to fix that while we wait for info from your developers?

    Thanks!

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.