Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save messica/39411d82d50fd9efab56159c5b896cc3 to your computer and use it in GitHub Desktop.
Save messica/39411d82d50fd9efab56159c5b896cc3 to your computer and use it in GitHub Desktop.
Remove trial if user has cancelled order for same level.
<?php
/**
* Remove trial if user has cancelled order for same level.
* Add code below to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function pmpro_remove_trial_for_existing_members( $level ) {
$order = new MemberOrder();
if ( $order->getLastMemberOrder( null, 'cancelled', $level->id ) ) {
$level->trial_limit = 0;
}
return $level;
}
add_action( 'pmpro_checkout_level', 'pmpro_remove_trial_for_existing_members' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment