Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save kimwhite/86e0aed1a860efa9847e1afec5e7743f to your computer and use it in GitHub Desktop.
Save kimwhite/86e0aed1a860efa9847e1afec5e7743f to your computer and use it in GitHub Desktop.
Set the initial amount to $0 for existing members.
<?php
/**
* Set the initial price to xxx for members only, for specific levels.
*
* Add this code to your site by following this guide - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_pmpro_adjust_initial_amount( $level ) {
// Define different prices for specific levels
$level_prices = array(
3 => 50, // Level ID 3 -> $50 initial payment
5 => 75, // Level ID 5 -> $75 initial payment
8 => 50 // Level ID 7 -> $100 initial payment
);
// Check if the level ID exists in the array and update the initial payment
if ( array_key_exists( $level->id, $level_prices ) ) {
$level->initial_payment = $level_prices[$level->id];
}
return $level;
}
add_filter( 'pmpro_checkout_level', 'my_pmpro_adjust_initial_amount' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment