Home / Disable / Remove Recurring Donation Time Periods
Duplicate Snippet

Embed Snippet on Your Site

Remove Recurring Donation Time Periods

This snippet removes some options for recurring donation periods with Charitable's Recurring Donations addon. This might reset or cause odd things to happen to campaigns who resave settings without updating the period if they already selected some period that is now removed. Just be aware.

Code Preview
php
<?php
/**
 * This snippet removes some options for recurring donation periods with Charitable's Recurring Donations addon.
 * This might reset or cause odd things to happen to campaigns who resave settings without updating the period if 
 * they already selected some period that is now removed. Just be aware.
 * 
 * This snippet was created Dec 2023 and works with Charitable 1.8.0+.
 *
 */
add_filter( 'charitable_recurring_get_donation_periods_for_campaign', 'charitable_remove_some_donation_periods', 10, 2 );
	function charitable_remove_some_donation_periods( $periods, $campaign ) {
		// The $periods looks like this
		// Array ( [once] => one-time [week] => weekly [month] => monthly [quarter] => quarterly [semiannual] => semiannually [year] => annually )
		unset( $periods['week'] );
		unset( $periods['quarter'] );
		unset( $periods['semiannual'] );
		return $periods;
	}

Comments

Add a Comment