Last active
July 4, 2019 18:25
-
-
Save LMNTL/4a3a514d9b61d9ce85440a352c4918e9 to your computer and use it in GitHub Desktop.
Don't show renewal link on the Levels page for Pay by Check users with pending orders
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
/** Don't show renewal link on the Levels page for Pay by Check users with pending orders | |
* Not compatible with the Advanced Levels Page Shortcode Add On; use this gist instead: https://gist.github.com/LMNTL/c8549aa27d259a21a2841560f4a2e1c5 | |
* requires Pay by Check Add On to be installed and configured | |
*/ | |
function my_pmprobc_no_renewal_before_approval( $show, $level ){ | |
// get the last order for the current user | |
$last_order = new MemberOrder(); | |
$last_order->getLastMemberOrder(NULL, NULL); | |
// bail if there wasn't a last order or it wasn't for this level | |
if( !isset( $last_order->membership_id ) || $last_order->membership_id != $level->id) | |
return $show; | |
// bail if the last order wasn't a check order or in "pending"/"review"/blank status | |
if( $last_order->gateway != "check" || !in_array( $last_order->status, array( "pending", "review", "" ) ) ) | |
return $show; | |
$show = false; | |
return $show; | |
} | |
add_filter( 'pmpro_is_level_expiring_soon', 'my_pmprobc_no_renewal_before_approval', 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment