Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
When user renews membership we append the duration to their current enddate
Plugin Name: Paid Memberships Pro: Extend membership by new level duration
Plugin URI:
Description: On change of level, modify the end date to add the new level's time
Version: 1.0
Requires: 4.5.3
Author: Thomas Sjolshagen <>
Author URI:
License: GPL2
License URI:
function e20r_extend_enddate_by_duration( $enddate, $user_id, $level, $startdate ) {
// If the user has a current membership level
if ( false !== ( $current_level = pmpro_getMembershipLevelForUser( $user_id ) )
&& ! empty( $level->expiration_number ) && ! empty( $level->expiration_period )
) {
$enddate = date( 'Y-m-d', strtotime( "+ {$level->expiration_number} {$level->expiration_period}", $current_level->enddate ) );
return $enddate;
add_filter( 'pmpro_checkout_end_date', 'e20r_extend_enddate_by_duration', 10, 4 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.