Forked from kimcoleman/pmprodon_pmpro_donation_recurring.php
Created
March 18, 2026 15:32
-
-
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/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?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