Home / Admin / Change Fields On Donation Form
Duplicate Snippet

Embed Snippet on Your Site

Change Fields On Donation Form

Example on how to change labels for fields on donation form.

Code Preview
php
<?php
add_action( 'wp', 'example_charitable_update_donation_fields' );
function example_charitable_update_donation_fields() {
	// Get the donation fields.
	$fields = charitable()->donation_fields();
	// Get the field we want to update.
	$field = $fields->get_field( 'state' );
	// Update the field's label to say "Province" on the donation form and admin form.
	$field->set( 'donation_form', 'label', 'Province' );
	$field->set( 'admin_form', 'label', 'Province' );
	// Repeat this for the postcode field.
	$field = $fields->get_field( 'postcode' );
	$field->set( 'donation_form', 'label', 'Postal' );
	$field->set( 'admin_form', 'label', 'Postal' );
	$fields->register_field( $field );
}

Comments

Add a Comment