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.

"Address" as a post custom field type

  1. Anonymous
    Unregistered

    I would like to request the "address" field be available as an option for the post custom field types.

    I am trying to parse Google maps on each post and need the full address in a single custom field. I haven't found a way to combine multiple custom fields (address, city, state, zip) into one field.

    Any chance of this happening in the next release?

    Posted 13 years ago on Wednesday November 10, 2010 | Permalink
  2. Anonymous
    Unregistered

    Well, I just found this post:

    http://forum.gravityhelp.com/topic/combining-fields

    Which is basically exactly what I need to do...Combine several GF custom fields into one.

    The link shown above involves combining dates and times. In my case it involves combining address fields (address, city, state, zip) into one custom field called "address".

    Could anyone lead me in the right direction on how to combine these fields into a single custom field?

    Posted 13 years ago on Wednesday November 10, 2010 | Permalink
  3. boumart
    Member

    Hello

    I 'm looking for the same, i'm quite sure you can't !

    Posted 13 years ago on Wednesday November 10, 2010 | Permalink
  4. You can accomplish that functionality using a hook.
    Place the following code snippet in your theme's functions.php. Make sure you replace the form id and field id variables. See notes below.

    //NOTE: CHANGE 10 (in gform_post_submission_10) TO YOUR ACTUAL FORM ID
    add_action("gform_post_submission_10", "set_post_content", 10, 2);
    function set_post_content($entry, $form){
    
        //NOTE: CHANGE THIS VALUE TO YOUR ACTUAL ADDRESS FIELD ID
        $address_field_id = 5;
    
        $street = $entry[$address_field_id . ".1"];
        $street2 = $entry[$address_field_id . ".2"];
        $city = $entry[$address_field_id . ".3"];
        $state = $entry[$address_field_id . ".4"];
        $zip = $entry[$address_field_id . ".5"];
        $country = $entry[$address_field_id . ".6"];
    
        $address = "{$street} {$street2} {$city}, {$state} {$zip} {$country}";
    
        add_post_meta($entry["post_id"], "address", $address);
    }
    Posted 13 years ago on Wednesday November 10, 2010 | Permalink
  5. It's not mentioned many places (that I could find) so confirming here:

    You find the Field ID by looking at the form on a page, and then finding the LI ID?

    For example: <div id="field_2_5"> would be for Field '5' in Form '2' and <input id="input_2_5_1"> would be the "Street Address" (first input of Field '5' in Form '2')?

    And so to pull the value from $entry where "input_2_5_1" matches gform_post_submission_2 and $entry["5.1"], correct?

    Posted 13 years ago on Monday January 10, 2011 | Permalink
  6. OK, I see that it is base off the "name" attribute of each input element...

    Posted 13 years ago on Monday January 10, 2011 | Permalink
  7. The code from Cancado actually didnt work for me. After modifying the code a bit this finally worked for me.

    //NOTE: CHANGE 10 (in gform_post_submission_1) TO YOUR ACTUAL FORM ID
    add_action("gform_post_submission_1", "set_post_content", 10, 2);
    function set_post_content($entry, $form){
    
        //NOTE: CHANGE THIS VALUE TO YOUR ACTUAL ADDRESS FIELD ID
        $address_field_id = 11;
    
        $streetaddress = $entry[6];
        $town = $entry[7];
        $province = $entry[8];
        $postalcode = $entry[9];
        $country = $entry[10];
    
        $geo_address = "{$streetaddress}, {$town}, {$province}, {$postalcode}, {$country}";
    
        add_post_meta($entry["post_id"], "geo_address", $geo_address);
    }
    Posted 12 years ago on Friday November 4, 2011 | Permalink