Skip to content

Instantly share code, notes, and snippets.

@kimwhite
Last active January 20, 2025 15:03
Show Gist options
  • Save kimwhite/e7acc1772f0e8779a29b05c27a86c8df to your computer and use it in GitHub Desktop.
Save kimwhite/e7acc1772f0e8779a29b05c27a86c8df to your computer and use it in GitHub Desktop.
<?php // do not copy this line.
/**
* This recipe will change the price for a membership by the date
*
* You can add this recipe to your site by creating a custom plugin
* or using the Code Snippets plugin available for free in the WordPress repository.
* Read this companion article for step-by-step directions on either method.
* https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function pmpro_checkout_sale_price( $level ) {
$month = date( 'n', current_time( 'timestamp' ) );
if ( $month == 12 ) {
//december
if ( $level->id == 2 ) {
$level->initial_payment = number_format( $level->initial_payment - 2, 2 );
}
}
return $level;
}
add_filter( 'pmpro_checkout_level', 'pmpro_checkout_sale_price' );
/* change price by month text */
function nicer_pmpro_level_cost_text($text, $level)
{
global $pmpro_pages;
$month = date( 'n', current_time( 'timestamp' ) );
if ( is_page( $pmpro_pages['levels']) && ( $month == 12 ) ) {
if ( $level->id == 2 ) {
$text = "Your what 2 text Here";
}
}
return $text;
}
add_filter("pmpro_level_cost_text", "nicer_pmpro_level_cost_text", 15, 2);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment