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

Remove Login Form

/** * Remove the login prompt from being displayed before the donation form. */ function ed_remove_login_form_before_donation_form() { remove_action( ‘charitable_donation_form_before’, ‘charitable_template_donation_form_login’, 4 ); } add_action( ‘after_setup_theme’, ‘ed_remove_login_form_before_donation_form’, 20 );Continue reading

Add Donation Receipt Opt Out Checkbox

/** * In this function we register a new donation field with a * key of `receipt_opt_out`. If the donor checks this, it means * they don’t want to receive their donation receipt. */ add_action( ‘init’, function() { $field =…Continue reading

Change Accepted Countries Per Campaign

/** * This example shows how to change the accepted countries list on a per-campaign basis. * * @param array $fields The fields in the form. * @return array */ function ed_set_list_of_accepted_countries_by_campaign( $fields, $form ) { /* If a country…Continue reading

Change Country Field To Hidden

/** * This code snipet shows how to change the Country field in the * donation form to a hidden field with a hard-coded default value. * * This shows in general how you can modify a donation field *…Continue reading

Set Default Donation Amount

/** * Set the default donation amount for all campaigns. * * @see https://github.com/Charitable/library/blob/master/donation-form/set-default-donation-amount-per-campaign.php * * @param float|int $amount The amount to be filtered. $0 by default. * @return float|int */ function ed_charitable_set_default_donation_amount( $amount ) { // Return a default…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