Forked from andrewlimaza/set-initial-price-to-0-for-members.php
Last active
February 28, 2025 14:10
-
-
Save kimwhite/86e0aed1a860efa9847e1afec5e7743f to your computer and use it in GitHub Desktop.
Set the initial amount to $0 for existing members.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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