Title: Expiration Problem
Last modified: December 3, 2017

---

# Expiration Problem

 *  Resolved [Leinad4Mind](https://wordpress.org/support/users/leinad4mind/)
 * (@leinad4mind)
 * [8 years, 5 months ago](https://wordpress.org/support/topic/expiration-problem/)
 * Hi there, when the users expire they are not being moved to the group I selected:
 *     ```
       /*
       	When users cancel (are changed to membership level 0) we give them another "cancelled" level. 
       	Can be used to downgrade someone to a free level when they cancel.
       	Will allow members to the "cancel level" to cancel from that though.
       */
       function my_pmpro_after_change_membership_level($level_id, $user_id)
       {
       	//set this to the id of the level you want to give members when they cancel
       	$cancel_level_id = 5;
   
       	//are they cancelling?
       	if($level_id == 0)
       	{
       		//check if they are cancelling from level $cancel_level_id
       		global $wpdb;
       		$last_level_id = $wpdb->get_var("SELECT membership_id FROM $wpdb->pmpro_memberships_users WHERE user_id = '" . $user_id . "' ORDER BY id DESC");
       		if($last_level_id == $cancel_level_id)
       			return;	//let them cancel
   
       		//otherwise give them level $cancel_level_id instead
       		pmpro_changeMembershipLevel($cancel_level_id, $user_id);
       	}
       }
       add_action("pmpro_after_change_membership_level", "my_pmpro_after_change_membership_level", 10, 2);
       ```
   
 * Why it doesn’t change? Why the users goes to the expired level? Instead of the
   one I told (level 5) ?
    -  This topic was modified 8 years, 5 months ago by [Leinad4Mind](https://wordpress.org/support/users/leinad4mind/).

Viewing 4 replies - 16 through 19 (of 19 total)

[←](https://wordpress.org/support/topic/expiration-problem/?output_format=md) [1](https://wordpress.org/support/topic/expiration-problem/?output_format=md)
2

 *  Thread Starter [Leinad4Mind](https://wordpress.org/support/users/leinad4mind/)
 * (@leinad4mind)
 * [8 years, 4 months ago](https://wordpress.org/support/topic/expiration-problem/page/2/#post-9847754)
 * Right now I’ve the last PMPro version I updated yesterday.
 * This is all modifications I’ve:
    [https://pastebin.com/emRfwmeK](https://pastebin.com/emRfwmeK)(
   The last function is the only one about this matter as you can see)
 * I’ve modified the page/checkout too, but I guess its not related to this. In 
   any case this was my modification at it: [https://www.diffchecker.com/srNLhvGB](https://www.diffchecker.com/srNLhvGB)
 * And thats all modifications I made.
 * Let me say that before PMPro I had Wishlist, but I convert the data to PMPro.
   
   And maybe wishlist had some bugs, because I found out this week that I’ve this
   too:
 * > [View post on imgur.com](https://imgur.com/82huHyA)
 * 
    3 active memberships for the same users (it happens to more users)
 * Dunno if my bug is related to this or if its related to have an expire date (
   1 year) with subscription (1 year).
    -  This reply was modified 8 years, 4 months ago by [Leinad4Mind](https://wordpress.org/support/users/leinad4mind/).
    -  This reply was modified 8 years, 4 months ago by [Leinad4Mind](https://wordpress.org/support/users/leinad4mind/).
 *  Plugin Author [Andrew Lima](https://wordpress.org/support/users/andrewza/)
 * (@andrewza)
 * [8 years, 4 months ago](https://wordpress.org/support/topic/expiration-problem/page/2/#post-9864710)
 * Thank you for the feedback, would you mind opening a thread on [http://www.paidmembershipspro.com](http://www.paidmembershipspro.com)
   so we may get higher level support to assist you much more than I can here.
 * The code gist you are using is slightly outdated, you may find the new version
   and documentation over here – [https://www.paidmembershipspro.com/change-membership-level-on-cancellation-or-expiration/](https://www.paidmembershipspro.com/change-membership-level-on-cancellation-or-expiration/)
   or on gist.github.com
 * Please update your code and let me know if this works as intended.
 *  Thread Starter [Leinad4Mind](https://wordpress.org/support/users/leinad4mind/)
 * (@leinad4mind)
 * [8 years, 4 months ago](https://wordpress.org/support/topic/expiration-problem/page/2/#post-9865490)
 * Thanks, but let me say no. I’m sorry but I’ll just buy a plan again if the membership
   is working. And probably my problem is about the configuration and not my code.
   
   Since I beleive it can be related to this doubt: [https://wordpress.org/support/topic/doubt-about-recurring-payments/](https://wordpress.org/support/topic/doubt-about-recurring-payments/)
 * And its something that should be replied here since its about the free version,
   not the paid one. Its a simple doubt. And very easy to reply.
 *  Plugin Author [Andrew Lima](https://wordpress.org/support/users/andrewza/)
 * (@andrewza)
 * [8 years, 4 months ago](https://wordpress.org/support/topic/expiration-problem/page/2/#post-9868057)
 * I have responded to your [https://wordpress.org/support/topic/doubt-about-recurring-payments/#post-9868056](https://wordpress.org/support/topic/doubt-about-recurring-payments/#post-9868056)
   and will continue to assist you on that thread to reduce confusion from our end
   🙂

Viewing 4 replies - 16 through 19 (of 19 total)

[←](https://wordpress.org/support/topic/expiration-problem/?output_format=md) [1](https://wordpress.org/support/topic/expiration-problem/?output_format=md)
2

The topic ‘Expiration Problem’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/paid-memberships-pro_f1dacb.svg)
 * [Paid Memberships Pro - Content Restriction, User Registration, & Paid Subscriptions](https://wordpress.org/plugins/paid-memberships-pro/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/paid-memberships-pro/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/paid-memberships-pro/)
 * [Active Topics](https://wordpress.org/support/plugin/paid-memberships-pro/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/paid-memberships-pro/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/paid-memberships-pro/reviews/)

 * 19 replies
 * 2 participants
 * Last reply from: [Andrew Lima](https://wordpress.org/support/users/andrewza/)
 * Last activity: [8 years, 4 months ago](https://wordpress.org/support/topic/expiration-problem/page/2/#post-9868057)
 * Status: resolved