Add Custom Field

/** * Display the custom field. * * @param Charitable_Campaign $campaign * @return void */ function ed_charitable_add_custom_field_to_campaign_grid( $campaign ) { echo $campaign->get( ‘my_custom_field’ ); } /** * You can adjust where the custom field is inserted by changing the priority,…Continue reading

Add Read More Link

/** * Add a Read More link to the campaigns in the campaign grid. * * Note: This is designed to be used for cases where you want a Read More link * as well as a Donate button. If…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

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

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

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

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

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

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

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