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
Join 2,000,000+ Professionals who use WPCode to Future-Proof Their Websites!
/** * 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 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 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
/** * Collect a checkbox field in the donation form. * * This snippet only works in Charitable 1.5 or above. * * Related examples: * * @see Register a text field (detailed example) – https://github.com/Charitable/library/blob/master/donation-form/register-new-donation-field-1.5.php * @see Register multiple…Continue reading
/** * In this example, a new donation field is created but left out of the * front-end donation form. Instead, it is dynamically set as a hidden * field in the donation form, based on the ID of the…Continue reading
/** * If you want to add multiple new fields to your donation form, * you can do that in a single function. * * In the example below, we add three separate fields: * * – a text field…Continue reading
/** * Add a text field to the donation form. * * This field is added to the donor details section (by default, this is the section * with a header of “Your Details”). In the example below, we add…Continue reading
/** * This example shows how to remove fields from the donation form. * * Note that this approach requires Charitable 1.6 or above. */ add_action( ‘init’, function() { if ( ! function_exists( ‘charitable’ ) ) { return; } $fields_api…Continue reading
/** * Change the “Postcode” field into a “ZIP Code” field. * * @param array[] $fields * @return array[] */ add_action( ‘init’, function ( $fields ) { $fields = charitable()->donation_fields(); $field = $fields->get_field( ‘postcode’ ); $field->label = ‘ZIP Code’; $field->set(…Continue reading
/** * This snippet shows you how you can easily add the campaign name * as a heading before the donation form. * * @param Charitable_Form $form * @return void */ function ed_show_campaign_title_before_donation_before( $form ) { if ( ! is_a(…Continue reading