Home / Archive / Change Section Headers Per Campaign
Duplicate Snippet

Embed Snippet on Your Site

Change Section Headers Per Campaign

Change the section headers in the donation form.

Code Preview
php
<?php
/**
 * 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 for the donation form for campaign #123.
		$fields['donation_fields']['legend'] = 'Custom Choose Your Donation Amount';
		$fields['details_fields']['legend'] = 'Custom Your Information';
		$fields['payment_fields']['legend'] = 'Custom Payment Information';
	} else {
		// Section headers for all other campaigns' donation forms.
		$fields['donation_fields']['legend'] = 'Choose Your Donation Amount';
		$fields['details_fields']['legend'] = 'Your Information';
		$fields['payment_fields']['legend'] = 'Payment Information';
	}
	// Finally, return the modified fields array.
	return $fields;
}
add_filter( 'charitable_donation_form_fields', 'ed_charitable_change_donation_form_section_headers_per_campaign', 20, 2 );

Comments

Add a Comment