Home / Archive / MemberPress: Change Non-Recurring Renewal Price
Duplicate Snippet

Embed Snippet on Your Site

MemberPress: Change Non-Recurring Renewal Price

This code snippet allows modification of a one-time membership’s price for renewals.

The code should be modified by replacing the dummy ID of 123 with the ID of the real one-time membership, on the following line:

if ( $product->ID === 123 && in_array( $product->ID, $subscriptions ) ) {

Further, the renewal price in the example is set to 10. The membership renewal price can be modified on this line:

$product_price = 10; // set the renewal price

Code Preview
php
<?php
function mepr_change_product_renewal_price( $product_price, $coupon_code, $product ) {
    $user = new MeprUser( get_current_user_id() );
    $subscriptions = $user->active_product_subscriptions( 'ids', true, true );
    // change the 123 ID to the required one-time membership ID
    if ( $product->ID === 123 && in_array( $product->ID, $subscriptions ) ) {
        $product_price = 10; // set the renewal price
    }
    return $product_price;
}
add_filter( 'mepr_adjusted_price', 'mepr_change_product_renewal_price', 10, 3 );

Comments

Add a Comment