Skip to content

Instantly share code, notes, and snippets.

@rickalday
Last active April 7, 2026 19:30
Show Gist options
  • Select an option

  • Save rickalday/d55c125d62a4e676934f99f4293b593c to your computer and use it in GitHub Desktop.

Select an option

Save rickalday/d55c125d62a4e676934f99f4293b593c to your computer and use it in GitHub Desktop.
Unrequire billing address block field for US in GiveWP visual builder forms
<?php
// Disable the custom billing address validation rules
add_filter( 'givewp_donation_form_validate_billing_address', function( $errors, $donation, $form_id ) {
// Clear all billing address related validation errors
if ( isset( $errors['billingAddress'] ) ) {
unset( $errors['billingAddress'] );
}
if ( isset( $errors['billingAddress.city'] ) ) {
unset( $errors['billingAddress.city'] );
}
if ( isset( $errors['billingAddress.state'] ) ) {
unset( $errors['billingAddress.state'] );
}
if ( isset( $errors['billingAddress.zip'] ) ) {
unset( $errors['billingAddress.zip'] );
}
return $errors;
}, 10, 3 );
// Also add the schema filter to remove them visually
add_action( 'givewp_donation_form_schema', function( $form ) {
$country = $form->getNodeByName( 'country' );
if ( ! $country ) {
return;
}
$address1 = $form->getNodeByName( 'address1' );
$city = $form->getNodeByName( 'city' );
$state = $form->getNodeByName( 'state' );
$postalCode = $form->getNodeByName( 'zip' );
$country->required( false );
$address1->required( false );
$city->required( false );
$state->required( false );
$postalCode->required( false );
// Remove the custom validation rules
try {
$cityRules = $city->getValidationRules();
$cityRules->removeRuleWithId( 'city' );
$stateRules = $state->getValidationRules();
$stateRules->removeRuleWithId( 'state' );
$zipRules = $postalCode->getValidationRules();
$zipRules->removeRuleWithId( 'zip' );
} catch ( Exception $e ) {
error_log( 'Error removing billing address validation rules: ' . $e->getMessage() );
}
} );
@rickalday

rickalday commented Apr 7, 2026

Copy link
Copy Markdown
Author

Add this CSS code to the form's Custom Styles panel or in GiveWP > Settings > Advanced > Donations Forms > Custom Styles

  /* Hide the required indicator (asterisk) for billing address city, state, and zip fields */
    .give-billing-address-block__city .give-form-label::after,
    .give-billing-address-block__state .give-form-label::after,
    .give-billing-address-block__zip .give-form-label::after {
        display: none !important;
    }
    
    /* Alternative: hide the entire required indicator for all billing address fields except country and address1 */
    .give-field__city .give-is-required,
    .give-field__state .give-is-required,
    .give-field__zip .give-is-required {
        display: none !important;
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment