Set Minimum Donation Amount

/** * Set the minimum donation amount required. * * This requires Charitable 1.5+. If you are using a previous version: * * @see https://github.com/Charitable/library/blob/master/donation-form/legacy/set-minimum-donation-amount.php */ function ed_charitable_set_minimum_donation_amount() { return 2; } add_filter( ‘charitable_minimum_donation_amount’, ‘ed_charitable_set_minimum_donation_amount’ );Continue reading

Change State To Province

/** * Change the “State” field into a “Province” field. * * @param array[] $fields * @return array[] */ add_action( ‘init’, function ( $fields ) { $fields = charitable()->donation_fields(); $field = $fields->get_field( ‘state’ ); $field->label = ‘Province’; $field->set( ‘donation_form’, ‘label’,…Continue reading

Add Select Field To Donation Form

/** * Add a select field to the donation form. * * Fields are added as a PHP array that define the field. * * This snippet only works in Charitable 1.5 or above. * */ function ed_charitable_register_new_select_field() { if…Continue reading

Change Custom Amount Field Label

/** * Filter the custom amount field description. * * @param string $label The default label. * @return string */ function ed_charitable_donation_form_set_custom_amount_field_text( $label ) { return ‘Your preferred label’; } add_filter( ‘charitable_donation_amount_form_custom_amount_text’, ‘ed_charitable_donation_form_set_custom_amount_field_text’ ); /* To use the same text…Continue reading

Require Us Phone Number Format

/** * This snippet shows how to alter the phone field so * that it only accepts a number between 8 and 12 digits * long, with an optional + at the start. * * However, this example more generally…Continue reading

Make Single Field Required

/** * Make a single field required. * * For an example showing how to make multiple fields required, see: * * @see https://github.com/Charitable/library/blob/master/donation-form/make-donor-address-required.php * * As of Charitable 1.6 the approach below is the recommended way of achieving this.…Continue reading

Set Maximum Donation Amount

/** * Set the maximum donation amount required. * * This function is called when the donation amount is validated, so it needs * to return either true or false. */ function ed_set_maximum_donation_amount( $valid, Charitable_Donation_Form_Interface $donation_form ) { /* Replace…Continue reading

Add Donation Form Shortcode

/** * Display a specific campaign’s donation form using a shortcode. * * After adding this code snippet, you can include any donation form with the following shortcode: * * [charitable_donation_form campaign=123] // Replace 123 with the ID of your…Continue reading

Change City Field To Select

/** * This code snipet shows how to change the City field in the * donation form to a selectable, dropdown field, with several * pre-set options. * * This shows in general how you can modify a donation field…Continue reading

Register New Donation Field

/** * In Charitable 1.5, the method for registering new * donation fields has become much simpler. The old way * will still work, but it’s more cumbersome and requires * much more code for the same effect. * *…Continue reading