How to populate the country and state fields of the Address field type with default values?

I’m using a GF form to let users validate their shipping address as we send the ordered bottles when the cask is being bottled, so that could be years after ordering them.

I have added a HTML section with the stored shipping address details and ask them to reply with a Yes / No Radio Buttons question. (When they select No, then they have to update their customer profile in the Woo shop first.)

As hidden field I want to use the Address field to store the shipping address data for easy export. It works for all items of the Address field except for the Country and State / Province / Region subfields.

On the Advanced tab I added {user:shipping_country} as default value for the country. But the subfield remains empty… why?

I already tried, without luck:

add_filter( 'gform_field_value_shipping_country', 'populate_country', 10 );
function populate_country( $value ) {
    if ( is_user_logged_in() ) {
        $current_user = wp_get_current_user();
	return get_user_meta( $current_user->ID, 'shipping_country', true );
    }
    return $value;
}

How can I get those dropdown subfields of the Address field all populated with the stored data?

Btw - not sure if it’s relevant, my form is a multi paged form.

Steven

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.