Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save MaximilianoRicoTabo/5bf7bc882ec88bce62470f8772059e2c to your computer and use it in GitHub Desktop.
Save MaximilianoRicoTabo/5bf7bc882ec88bce62470f8772059e2c to your computer and use it in GitHub Desktop.
<?php // do not copy this line.
/**
* This recipe does 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 ( in_array( $month, array( 1, 2, 3 ) ) ) {
$level->initial_payment = number_format( $level->initial_payment + 20, 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'] ) && in_array( $month, array( 1, 2, 3 ) ) ) {
//Change this text below to match your needs.
$text = number_format( $level->initial_payment + 20, 2 ) . " includes 20 as a late checout fee.";
}
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