Forked from andrewlimaza/remove-custom-trial-for-existing-members.php
Last active
April 14, 2021 11:10
-
-
Save femiyb/fd875a7708d537c83efe7e240dae7052 to your computer and use it in GitHub Desktop.
Remove trial limit for existing members. [Paid Memberships Pro]
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 | |
/** | |
* Remove custom trial for existing members (when existing member changes levels/renews) | |
* Adjust the level ID on line 15 to match your needs. | |
* Add this code to your WordPress site by following this guide - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/ | |
*/ | |
function my_pmpro_level_adjustment( $level ) { | |
// Bail if the user currently doesn't have a membership level. | |
if ( ! pmpro_hasMembershipLevel() ) { | |
return $level; | |
} | |
$trial_levels = array( 1, 2 ); | |
// If it's not the level with the trial amount, just bail. | |
if( !in_array( $level->id, $trial_levels ) ) { | |
return $level; | |
} | |
$level->trial_limit = '0'; | |
$level->trial_amount = '0'; | |
return $level; | |
} | |
add_filter( 'pmpro_checkout_level', 'my_pmpro_level_adjustment', 10, 1 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Line 15