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.

Mailchimp pre-populating content into address fields not working

  1. chezolio
    Member

    Hey guys, working on a site for a band that wants to segment their mailing list subscribers by region for tour specific campaigns. Thing is they don't want to ask for full addresses, just zip code.

    What I am trying to do is hide all of the address fields except zip code, populate the hidden fields with php and send it all to Mailchimp for regional list segmenting.

    I'm using this to populate the fields, which works fine:

    add_filter("gform_field_value_street", "populate_street");
    function populate_street($value){
        return "123 Fake St";
    }
    
    add_filter("gform_field_value_city", "populate_city");
    function populate_city($value){
        return "Anytown";
    }
    
    add_filter("gform_field_value_country", "populate_country");
    function populate_country($value){
        return "US";
    }

    Problem is, when I send it off, nothing shows up in the Mailchimp user's address. It does show up however if I remove the code above and enter everything in the address field manually.

    Posted 13 years ago on Thursday April 28, 2011 | Permalink
  2. Have you tried using a Single Text field for the zip code input instead of the Address field and testing to see if that works?

    Posted 13 years ago on Thursday April 28, 2011 | Permalink
  3. chezolio
    Member

    I have. Mailchimp only accepts address info as an array, so individual fields are problematic.

    Posted 13 years ago on Thursday April 28, 2011 | Permalink
  4. When you view the entries for the forms you submitted pre-populating that data, is your address information there?

    Posted 13 years ago on Friday April 29, 2011 | Permalink
  5. chezolio
    Member

    Yes, the pre-populated data does show up in the entries stored in the database, as well as the zip code entered. It just doesn't get stored in Mailchimp. It's just a test mailchimp account at this point so I'll send you the login details and the wp admin login details too.

    Posted 13 years ago on Friday April 29, 2011 | Permalink
  6. There are a couple issues with what you are trying to do.

    First you are populating the country field with just "US" instead of "UNITED STATES" which means "United States" isn't getting pre-selected because "US" isn't an existing value. So you need to set the country to "United States" and not "US".

    Your second issue is you aren't populating the state field. The state field is required by MailChimp. If you don't pass it, the Address field won't get populated. MailChimp's Address field will not populate unless all the required fields are passed to it. If they aren't, MailChimp ignores it.

    So here is what you need to use:

    add_filter("gform_field_value_street", "populate_street");
    function populate_street($value){
        return "123 Fake St";
    }
    
    add_filter("gform_field_value_city", "populate_city");
    function populate_city($value){
        return "Anytown";
    }
    
    add_filter("gform_field_value_country", "populate_country");
    function populate_country($value){
        return "United States";
    }
    
    add_filter("gform_field_value_state", "populate_state");
    function populate_state($value){
        return "VA";
    }

    You can change the state value to whatever you want. I used VA just because we are in Virginia.

    Posted 13 years ago on Monday May 9, 2011 | Permalink