Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save femiyb/fd875a7708d537c83efe7e240dae7052 to your computer and use it in GitHub Desktop.
Save femiyb/fd875a7708d537c83efe7e240dae7052 to your computer and use it in GitHub Desktop.
Remove trial limit for existing members. [Paid Memberships Pro]
<?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 );
@kimwhite
Copy link

Line 15

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment