Of of the coolest features in the recent 2.5 release of Restrict Content Pro is the new ability to automatically prorate a user’s upgrade price. The way this works is if a user purchases a subscription for $10 and then changes his mind and wants the $20 plan instead, he is credited that $10 on the upgrade and the initial price of the new plan is just $10.
We built some smart logic into this too, so RCP will actually calculate the value of the remainder of the current subscription and only credit the appropriate amount. So taken the above example, if a user subscribes to the $10 plan and then decides to upgrade half way through a term, then he is credited $5 toward the upgrade.
But what if you don’t want RCP to prorate plan upgrades/downgrades? Or perhaps you want to build in some logic and define which plans should get prorated.
Let’s start with the first one. This one is pretty easy. If you are working on a custom theme or want to build your own plugin, simply copy in the following code:
add_filter( 'rcp_disable_prorate_credit', '__return_true' );
If you want to build out some custom logic, you’ll use the same filter but instead of using the __return_true function, you’ll hook it into your own function. Something like this:
add_filter( 'rcp_disable_prorate_credit', 'my_custom_proration_function', 10, 2 );
Make sure you specify the priority (the 10) and the number of arguments to receive (the 2) as that will give you access to the user object. You can find out more about this filter in the class-rcp-member.php file on line 686.
Just as a side note, if you need to rewrite the proration functionality use the rcp_member_prorate_credit filter defined on line 760 of class-rcp-member.php.