In the core PMPro plugin, members who complete checkout for their current level will automatically have an expiration date extend one additional term from their current expiration. This means that a member who would be expiring in 2 weeks can renew their annual plan today. Their new expiration date is now 54 weeks from the checkout date.
The code recipe below demonstrates how you can apply that same logic to membership level changes. I’ll also explain how you could set up two new “Extension” levels and allow members to buy a 30 or 60 day extension.
The recipe below will apply all of the core logic to add the remaining time on the member’s current level to their new level. Members on a “Bronze” plan with two months remaining can upgrade to your “Gold” annual plan and immediately access all “Gold” level content. Their expiration date will be set for 1 year + 2 months from the checkout date.
Extending membership (or not) is a decision you as the membership site owner needs to figure out. In the scenario above, the member will be getting two “discounted” months of your top membership level. Without the code recipe, that same member will, in theory, “lose” two months of their current membership.
You’ll need to choose what fits for your project. Just have your explanation ready if a customer ever asks what happened to those 2 lost months of membership.
The Code Recipe: Allow Renewal Extension
Allow a 30 or 60 day Membership Extension
In order to allow members to purchase an extension, you’ll need to create one or two new membership levels with the appropriate expiration date. This extension can be priced as a direct monthly rate based on your annual plan pricing OR you can price it a little bit higher. Most sites offer a discount on annual membership and bump prices for users that pay monthly.
You can hide these levels from the Membership Levels page using the “levels” attribute of the shortcode in the Advanced Levels Page Add On documented here.
When a user completes checkout for one of these two 30 or 60 day “extension levels”, it will add those days to their current plan and push the expiration date out for the appropriate time period.
Moving Members to a Recurring Membership
Remember, Paid Memberships Pro has built-in membership extension logic for all users that renew their fixed-term membership. This means that if I am on a fixed 1 year membership on your site that expires in 14 days, I can check out for the same plan and extend my membership one year PLUS 14 days from now. No custom code is required for this to work.
If a member with expiration in 14 days completes checkout for a new annual subscription plan (no expiration, automatic renewals), their membership and renewal date will begin immediately with no “extension”.