Created
October 5, 2016 23:03
-
-
Save mindctrl/20ba6ab4a25ec0e0f4369231239febc2 to your computer and use it in GitHub Desktop.
Restrict Content Pro - Prevent subscription downgrades
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_downgrades( $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_downgrades', 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment