Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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