Add Empty Option To Countries List

/** * In this example we add an empty “Select your country” * option at the start of the list of countries in the * donation form. */ add_action( ‘init’, function() { $fields = charitable()->donation_fields(); $field = $fields->get_field( ‘country’ );…Continue reading

Change Section Headers Per Campaign

/** * Change the section headers in the donation form. * * @param array $fields All the donation form fields. * @return array */ function ed_charitable_change_donation_form_section_headers_per_campaign( $fields, $form ) { if ( 123 === $form->get_campaign()->ID ) { // Section headers…Continue reading

Allow Zero Dollar Donations

/** * Allow people to “donate” $0. */ function ed_charitable_set_minimum_donation_amount() { return 0; } add_filter( ‘charitable_minimum_donation_amount’, ‘ed_charitable_set_minimum_donation_amount’ ); /** * You need to specifically enable $0 donations. */ add_filter( ‘charitable_permit_0_donation’, ‘__return_true’ );Continue reading

Add User Field

/** * This adds a field to the end of the “Your Details” section in the Profile form. * * In this example, we add a Birthday field, which is a date field. * * @param array $fields * @param…Continue reading

Remove Organisation Field

/** * Remove “organisation” from the profile form. */ function ed_remove_organisation_from_profile( $fields ) { unset( $fields[ ‘organisation’ ] ); return $fields; } add_filter( ‘charitable_user_fields’, ‘ed_remove_organisation_from_profile’ );Continue reading

Remove Section

/** * You may decide that you do not need some of the sections in the Profile form at all. * This code will allow you to remove an entire section. * * If you just want to remove individual…Continue reading

Keep Username As Display Name

/** * When people update their profile, keep their display name set to * be the same as their login name (username). */ function ed_charitable_keep_original_display_name( $values ) { $values[‘display_name’] = wp_get_current_user()->user_login; return $values; } add_filter( ‘charitable_profile_update_values’, ‘ed_charitable_keep_original_display_name’ ); add_filter( ‘charitable_campaign_submission_user_data’,…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

Customize Amount Raised Text

/** * In this example, we change how the “X donated of Y goal” text appears. * * @param string $summary The summary. * @param Charitable_Campaign $campaign This campaign object. * @param float $amount The amount donated. * @param int…Continue reading