Skip to content

Instantly share code, notes, and snippets.

@strangerstudios
Created August 17, 2017 16:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save strangerstudios/425c024d711e65480d53edef783e6fa1 to your computer and use it in GitHub Desktop.
Save strangerstudios/425c024d711e65480d53edef783e6fa1 to your computer and use it in GitHub Desktop.
Discount a Paid Memberships Pro level half way through the year.
<?php
/*
Add this code into a custom plugin. Combine this with the pmpro-set-expiration-date and/or pmpro-subscription-delay plugins
to have memberships expire/renew on the same date, e.g. Y2-01-01 to expire/renew on Jan 1 next year.
You can update the logic to check for different months or adjust the price in a different way. The code below divides the
initial payment by 2 July 1 through Dec 31.
*/
function pmpro_checkout_level_half_off_mid_year($level) {
$month = date('n', current_time('timestamp');
if($month > 6) {
//July or later
if($level->initial_payment > 0)
$level->initial_payment = number_format($level->initial_payment/2, 2);
}
return $level;
}
add_filter('pmpro_checkout_level', 'pmpro_checkout_level_half_off_mid_year');
@ideadude
Copy link

There is an error on line 10. We can't edit these gists under the strangerstudios user anymore. You can find the updated/fixed gist here: https://gist.github.com/kimcoleman/4d494574fe9a64285ab94effd6ccf3d9

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment