I had previously set up custom profile fields for mailing and billing addresses so that I could use Gravity Forms built in custom & user meta merge tags to auto populate fields in order forms.

When I tried adding WP Customer Area (CA) so that the client could upload digital files (excel spreadsheets) privately to users I discovered that CA stored the addresses as wp_option data instead of user meta data. This made the addresses incompatible with auto population via Gravity Forms Merge Tags.

Through way more time than I care to admit and with a little help of someone else I managed to accomplish storing the data both as wp_option data as well as user_metadata to make it compatible with what I was doing.

The below is the code to add to your theme’s functions.php file (for just the Home Address City as a proof of concept):


// Save Customer Area address as user_metadata as well as option data
add_action( 'init', function() {

$user_id = get_current_user_ID();
$user_type = ‘usr’;

add_filter( “pre_update_option_cuar_owner_addresses|{$user_type}|{$user_id}”, ‘cuar_usermeta_update’, 10, 2 );
} );

function cuar_usermeta_update( $new_value, $old_value ) {

$user_id = get_current_user_ID();

if ( ! current_user_can( ‘edit_user’, $user_id ) ) {
return false;
}

// Copy & paste the below line and edit [‘home_address’][‘city’] accordingly based on form input field on edit address page
update_usermeta( absint( $user_id ), ‘mailing_address_city’, sanitize_text_field( $_POST[‘home_address’][‘city’] ) );

return $new_value;
}

References:
Add Custom Profile Fields To WordPress
Gravity Forms – Merge Tags