Forked from travislima/show-renewal-link-after-X-days-or-less.php
Last active
January 3, 2023 15:20
-
-
Save kimwhite/d390bf56c9e7e443b8b3b96c8f0a58c0 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 // 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. line 18 | |
* | |
* You can add this recipe to your site by creating a custom plugin | |
* or using the Code Snippets plugin available for free in the WordPress repository. | |
* Read this companion article for step-by-step directions on either method. | |
* 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