Set Fixed Donation Amount

/** * Automatically set the donation amount and recurring * period for donations. * * @param array $fields * @return array */ function ed_charitable_set_donation_amount( $fields ) { unset( $fields[‘donation_fields’] ); // The amount you would like to donate. $amount =…Continue reading

Remove Terms Fields

/** * If you would like to enable the terms and conditions, privacy * policy and user contact consent fields in the registration form * but NOT the donation form, you can add the following bit of code. */ add_filter(…Continue reading

Move User Fields In Donation Form

/** * In this example we move the user fields section (the “Your Details” bit) to * appear below the payment fields. */ function ed_charitable_move_user_fields_in_donation_form( $fields ) { if ( ! array_key_exists( ‘details_fields’, $fields ) ) { $fields[‘user_fields’][‘priority’] = 80;…Continue reading

Change Custom Amount Field Label Per Campaign

/** * Filter the custom amount field description on a per campaign basis. * * @param string $label The default label. * @return string */ function ed_charitable_donation_form_set_custom_amount_field_text_per_campaign( $label ) { $campaign_id = charitable_get_current_campaign_id(); if ( 226 === $campaign_id ) {…Continue reading

Set State Field To Us States Dropdown With Default

/** * 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’ ); // Change it to a select/drop-down…Continue reading

Multi Step Donation Form

/** * This snippet provides a foundation for converting the donation form * into a multi-step donation form. */ add_action( ‘charitable_donation_form_before’, function() { ?>Continue reading

Move Fields

/** * Move fields in the Donation Form. * * In the example below, we move the email field to show at priority 3 (before the first name) * and the phone field to show at priority 9 (before the…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

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

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