Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save kimwhite/e702b5517fe5b1558ff62428f04d9e02 to your computer and use it in GitHub Desktop.

Select an option

Save kimwhite/e702b5517fe5b1558ff62428f04d9e02 to your computer and use it in GitHub Desktop.
Adds recurring donation functionality to the Donations Add On for Paid Memberships Pro: https://www.paidmembershipspro.com/add-ons/donations-add-on/
<?php
/*
* This gist adds recurring functionality to the Donations Add On for Paid Memberships Pro.
* It adds the user-entered 'donation amount' to their recurring billing amount.
*/
//add donation amount to recurring payment amount
function pmprodon_pmpro_donation_recurring( $level ) {
if ( ! isset( $_REQUEST['donation'] ) ) {
return $level;
}
$donation = preg_replace( '/[^0-9.]/', '', $_REQUEST['donation'] );
if ( ! empty( $donation ) && $donation > 0 ) {
$level->billing_amount = $level->billing_amount + $donation;
}
return $level;
}
add_filter( 'pmpro_checkout_level', 'pmprodon_pmpro_donation_recurring', 100 ); // priority 100, runs AFTER the plugin's 99
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment