Skip to content

Instantly share code, notes, and snippets.

View toddcavanaugh's full-sized avatar

Todd toddcavanaugh

View GitHub Profile
@strangerstudios
strangerstudios / pmpro_cancel_on_next_payments_date.php
Last active May 20, 2021 11:17
Change PMPro membership cancellation to set expiration date for next payment instead of cancelling immediately.
/*
Change cancellation to set expiration date for next payment instead of cancelling immediately.
Assumes orders are generated for each payment (i.e. your webhooks/etc are setup correctly).
Since 2015-09-21 and PMPro v1.8.5.6 contains code to look up next payment dates via Stripe and PayPal Express APIs.
*/
//before cancelling, save the next_payment_timestamp to a global for later use. (Requires PMPro 1.8.5.6 or higher.)
function my_pmpro_before_change_membership_level($level_id, $user_id) {
//are we on the cancel page?