Hi Luo,
you can test it within toolset plugins, it's the same site as what we were working on together whole of last week.
I will tackle the most important of questions here, since i get an error and site isn't reachable when i added your codes in functions.php more than once.
Earlier we had (good working):
$t2 = $_POST['t2'];
$user_id = $post_id;
update_user_meta($user_id, 'wpcf-t2', $t2);
(ATTENTION: 'wpcf-t2' was NOT what you wrote earlier, you adviced: update_user_meta($user_id, 'wpcf-billing-addresses', $t2); <-- this works)
Now i added:
$t3 = $_POST['t3'];
$user_id = $post_id;
update_user_meta($user_id, 'wpcf-billing-addressesXXX', $t3);
and it gives an error.
We could see and edit the field in /account-details/ but can edit that field only when it belongs to 't2'. That's why i started now adding the other 't3', 't4', ... Note that i changed names of 't2' etc to relevant new names for easier identification.
What i did step by step to add the regions:
1) make new country in user fields and in products taxonomy
2) make new view for this region (duplicate and edit)
3) make new entry in user field group 'billing addresses'
4) edit cred user forms with new entries
5) add new entries to functions.php
I set functions.php back how it was so the site's functional. This is what i had there, not working:
add_action('cred_save_data', 'update_user_field_func',10,2);
function update_user_field_func($post_id, $form_data)
{
// if a specific form
if (in_array($form_data['id'], array(800, 838))){
$BABelux = $_POST['BABelux'];
$user_id = $post_id;
update_user_meta($user_id, 'wpcf-billing-addresses-belux', $BABelux);
}
}
add_action('cred_save_data', 'update_user_field_func',10,2);
function update_user_field_func($post_id, $form_data)
{
// if a specific form
if (in_array($form_data['id'], array(800, 838))){
$BANL = $_POST['BANL'];
$user_id = $post_id;
update_user_meta($user_id, 'wpcf-billing-addresses-nl', $BANL);
}
}