Forked from andrewlimaza/show-renewal-link-on-30-days-or-less.php
Created
December 15, 2022 14:36
-
-
Save kimwhite/147c8e8eba9da69f8235b7182348a4e1 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 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 | |
/** | |
* 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