Set a default value to donation form custom field
-
Hello,
Is it possible to add a default value for an additional form field?
I’ve referred to this https://givewp.com/documentation/developers/how-to-create-custom-form-fields/ article and made an additional text field. But I need to add a default value for that text field.
Ex: I need an additional form field called “Birth City” in the donation form and its default value should be “London”
add_action( ‘give_fields_after_donation_amount’, function( $collection ) {
$collection->append(
give_field( ‘text’, ‘Birth City” )
->showInReceipt()
->label( __(‘Birth City’) )
->value(‘London’)
->storeAsDonorMeta()
->required()
->helpText( __( ‘This is a field used to add your birth city.’ ) )
);
});I just added this code, but it shows an error. Please advice
Thanks
- The topic ‘Set a default value to donation form custom field’ is closed to new replies.