Skip to content

Instantly share code, notes, and snippets.

@mindctrl
Created October 5, 2016 23:03
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mindctrl/20ba6ab4a25ec0e0f4369231239febc2 to your computer and use it in GitHub Desktop.
Save mindctrl/20ba6ab4a25ec0e0f4369231239febc2 to your computer and use it in GitHub Desktop.
Restrict Content Pro - Prevent subscription downgrades
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