Problem:
The customer asked how the WordPress user "Language" field can be set through the Toolset's user form.
Solution:
Informed that there is no built-in method available in the Toolset Forms for this, so it will require some workaround and custom code.
WordPress store's the ISO language code for the user's selected WordPress admin language as a value, in the user meta field with key 'locale'.
In a user registration form, one can include a hidden generic field and fill its value with the language code of the current page's language. After that, the 'cred_save_data' hook can be used to programmatically set that selected language value into the user's 'locale' meta field:
add_action('cred_save_data', 'my_save_data_action',10,2);
function my_save_data_action($user_id, $form_data)
{
// if a specific form
if ($form_data['id']==1234)
{
update_user_meta( $user_id, 'locale', $_POST['locale'] );
}
}
Relevant Documentation:
https://toolset.com/documentation/programmer-reference/cred-api/#cred_save_data
https://developer.wordpress.org/reference/functions/update_user_meta/