Last active
January 23, 2023 13:47
-
-
Save andrewlimaza/147e5f021d744b474ada76305e062d8f to your computer and use it in GitHub Desktop.
Change when to show the renewal link on Paid Memberships Pro account page.
This file contains 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 | |
/** | |
* This will only show renewal date within 30 days or less than the members expiration. | |
* Add this code from line 7+ to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/ | |
* Visit www.paidmembershipspro.com for help. | |
*/ | |
function show_renewal_link_on_30_days( $r, $level ) { | |
if ( empty( $level->enddate ) ) { | |
return false; | |
} | |
$days = 30; // Change this to value. | |
// Are we within the days until expiration? | |
$now = current_time( 'timestamp' ); | |
if ( $now + ( $days * 3600 * 24 ) >= $level->enddate ) { | |
$r = true; | |
} else { | |
$r = false; | |
} | |
return $r; | |
} | |
add_filter( 'pmpro_is_level_expiring_soon', 'show_renewal_link_on_30_days', 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If you want to always show the renewal link, use this line of code instead of this entire function:
add_filter( 'pmpro_is_level_expiring_soon', '__return_true' );