Forked from andrewlimaza/show-renewal-link-on-30-days-or-less.php
Last active
March 24, 2023 18:09
-
-
Save travislima/498ca1363ddc1dca5279780c81812bb1 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 // be mindful about not duplicating this tag in your customizations plugin. | |
/** | |
* This will show the renewal date link within the number of days or less than the members expiration that you set in the code gist below. | |
* Add this code to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/ | |
*/ | |
function show_renewal_link_after_X_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_after_X_days', 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This recipe is included in the blog post on "Choose when to display the Renew link to members who sign up for a membership level with an expiration date." at Paid Memberships Pro here.