Add Field Placeholders

/** * Add placeholder attributes to donation fields, removing the label field. * * @return void */ add_action( ‘init’, function() { $fields = charitable()->donation_fields(); foreach ( $fields->get_donation_form_fields() as $field ) { $label = $field->donation_form[‘label’]; if ( isset( $field->donation_form[‘required’] ) &&…Continue reading

Change Section Headers

/** * 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( $fields ) { // “Your Donation” $fields[‘donation_fields’][‘legend’] = ‘Choose Your Donation Amount’; // “Details”…Continue reading

Register New Donation Field

/** * In Charitable 1.5, the method for registering new * donation fields has become much simpler. The old way * will still work, but it’s more cumbersome and requires * much more code for the same effect. * *…Continue reading

Add Donation Form Shortcode

/** * Display a specific campaign’s donation form using a shortcode. * * After adding this code snippet, you can include any donation form with the following shortcode: * * [charitable_donation_form campaign=123] // Replace 123 with the ID of your…Continue reading

Collect National Id Number

/** * 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

Add Dynamic Hidden Field

/** * 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

Add Checkbox Field To Donation Form

/** * 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

Display Donation Form

/** * Display a specific campaign’s donation form. * * To integrate this snippet, you will need to insert it * into a custom template in your theme. */ /* Replace 123 with the ID of the campaign. */ $campaign_id…Continue reading

Add Picture Field To Donation Form

/** * In this example, a picture field is added to the donation form, * allowing donors to upload an image as part of the donation process. * * The picture ID is added in the donation meta, with a…Continue reading