Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andrewlimaza/ba14f4c6f2d36167557518ea1f0746dc to your computer and use it in GitHub Desktop.
Save andrewlimaza/ba14f4c6f2d36167557518ea1f0746dc to your computer and use it in GitHub Desktop.
Change Set Expiration Date value for existing members/renewals
<?php
/**
* Changes the Y-M-D value for existing members when using the Set Expiration Date Add On.
* Allows you to extend renewal dates for Set Expiration Dates Add On
* Add this code to your site by following this guide - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_pmpro_change_set_expiration_renewal_date( $date ) {
global $pmpro_pages, $pmpro_level;
// Only change it on checkout page.
if ( ! is_page( $pmpro_pages['checkout'] ) ) {
return $date;
}
// If current user doesn't have a membership level, don't change the date.
if ( ! pmpro_hasMembershipLevel() ) {
return $date;
}
// Only if the checkout level has a set expiration date, change it.
if ( ! empty( $pmpro_level ) && pmpro_getSetExpirationDate( $pmpro_level->id ) ) {
$date = 'Y2-12-31'; //change this here for the renewal date.
}
return $date;
}
add_filter( 'pmprosed_expiration_date_raw', 'my_pmpro_change_set_expiration_renewal_date', 10, 1 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment