PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Change City label to Suburb

  1. lowercase
    Member

    I am trying to change the 'city' label in the address filed to 'Suburb'.
    I am using filters within functions.php but it keeps breaking when i add this filter.

    My funcitons code is here...

    <?php
    /**
    * @package WordPress
    * @subpackage Default_Theme
    */

    if ( function_exists('register_sidebar') ) {
    register_sidebar(array(
    'before_widget' => '<li id="%1$s" class="widget %2$s">',
    'after_widget' => '',
    'before_title' => '<h2 class="widgettitle">',
    'after_title' => '</h2>',
    ));
    }

    ?>
    <?php
    add_filter("gform_address_types", "aus_address", 10, 2);
    function aus_address($address_types, $form_id){
    $address_types["australia"] = array(
    "label" => "Australia",
    "country" => "Australia",
    "zip_label" => "Postcode",
    "state_label" => "State",
    "states" => array("NT"=>"NT", "ACT"=>"ACT","NSW"=>"NSW", "QLD"=>"QLD", "VIC"=>"VIC", "WA"=>"WA","SA"=>"SA", "TAS" => "TAS")
    );
    return $address_types;
    }
    ?>

    ?>
    How do i now add the label change to above code without it breaking the site?

    Posted 11 years ago on Wednesday June 5, 2013 | Permalink
  2. Richard Vav
    Administrator

    When you copy a function from the documentation you don't need to copy the opening <?php and ?> closing php tags as they are usually already present at the top and bottom of functions files, so your file should look more like this

    <?php
    /**
    * @package WordPress
    * @subpackage Default_Theme
    */
    
    if ( function_exists('register_sidebar') ) {
    register_sidebar(array(
    'before_widget' => '<li id="%1$s" class="widget %2$s">',
    'after_widget' => '',
    'before_title' => '<h2 class="widgettitle">',
    'after_title' => '</h2>',
    ));
    }
    
    add_filter("gform_address_types", "aus_address", 10, 2);
    function aus_address($address_types, $form_id){
    $address_types["australia"] = array(
    "label" => "Australia",
    "country" => "Australia",
    "zip_label" => "Postcode",
    "state_label" => "State",
    "states" => array("NT"=>"NT", "ACT"=>"ACT","NSW"=>"NSW", "QLD"=>"QLD", "VIC"=>"VIC", "WA"=>"WA","SA"=>"SA", "TAS" => "TAS")
    );
    return $address_types;
    }
    
    add_filter("gform_address_city", "change_address_city", 10, 2);
    function change_address_city($label, $form_id){
        return "Suburb";
    }
    
    ?>

    Regards,
    Richard

    Posted 11 years ago on Wednesday June 5, 2013 | Permalink