Created
October 5, 2016 23:06
-
-
Save mindctrl/b2c498e4fbdc946674a010c2d985c6cd to your computer and use it in GitHub Desktop.
Restrict Content Pro - Prevent subscription upgrades
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
function jp_rcp_prevent_subscription_upgrades( $levels, $user_id ) { | |
if ( ! is_user_logged_in() ) { | |
return $levels; | |
} | |
$existing_level = rcp_get_subscription_id( $user_id ); | |
if ( empty( $existing_level ) ) { | |
return $levels; | |
} | |
foreach ( $levels as $key => $level ) { | |
if ( rcp_get_subscription_price( $level->id ) > rcp_get_subscription_price( $existing_level ) ) { | |
unset( $levels[$key] ); | |
} | |
} | |
return $levels; | |
} | |
add_filter( 'rcp_get_upgrade_paths', 'jp_rcp_prevent_subscription_upgrades', 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment