Created
December 21, 2020 10:47
-
-
Save andrewlimaza/ba14f4c6f2d36167557518ea1f0746dc to your computer and use it in GitHub Desktop.
Change Set Expiration Date value for existing members/renewals
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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