4

Im trying to further customise my Gravity Forms "Address" labels. At the moment they read "Street Address", "City" and "ZIP / Postal Code".

I, for example, want to change "ZIP / Postal Code" to "Post code". Does anyone know if you can use templates to override these values in your theme without messing up the core GF files?

common.php seems to be the place where these values are stored:

public static function get_address_types($form_id){

    $addressTypes = array(
        "international" =>  array("label" => __("International", "gravityforms"),"zip_label" => apply_filters("gform_address_zip_{$form_id}",apply_filters("gform_address_zip", __("ZIP / Postal Code", "gravityforms"), $form_id), $form_id),"state_label" => apply_filters("gform_address_state_{$form_id}",apply_filters("gform_address_state",__("State / Province / Region", "gravityforms"), $form_id), $form_id)),
        );

    return apply_filters("gform_address_types_{$form_id}", apply_filters("gform_address_types", $addressTypes, $form_id), $form_id);
}

Any help would be appreciated. Thanks in advance.

closed as off-topic by Pat J, Johannes Pille, fuxia Jul 31 '14 at 19:45

This question appears to be off-topic. The users who voted to close gave this specific reason:

If this question can be reworded to fit the rules in the help center, please edit the question.

2

You can change a bunch in one hit with the gform_address_types filter, like this:

/**
* customise the Address field labels
* @param array $addressTypes
* @return array
*/
add_filter('gform_address_types', function ($addressTypes) {
    $addressTypes['international']['zip_label'] = 'Postcode';
    $addressTypes['international']['state_label'] = 'State';

    return $addressTypes;
});
1

You sure can. Gravity Forms has a bunch of hooks and filters set up for you.

So you can filter the various sublabels:

add_filter( 'gform_address_zip', 'call_it_a_post_code', 10, 2 );
function call_it_a_post_code( $label, $form_id ) {
    return 'Post code';
}

...should do what you want for your "Post code" example.

Not the answer you're looking for? Browse other questions tagged or ask your own question.