I have been struggling with this for days now. Maybe the fact that I dont code plays a role.
I used several iterations of snippets presented by AI, all failed.
This is the latest:
function sync_xprofile_to_user_meta($user_id) {
$fields = bp_xprofile_get_fields_by_group();
foreach ($fields as $field) {
$field_value = xprofile_get_field_data($field->id, $user_id);
update_user_meta($user_id, ‘xprofile_’ . $field->name, $field_value);
}
}
add_action(‘xprofile_updated_profile’, ‘sync_xprofile_to_user_meta’);
// This function is not automatically executed
function sync_all_xprofile_to_user_meta() {
$users = get_users();
foreach ($users as $user) {
sync_xprofile_to_user_meta($user->ID);
}
}
I think this one caused critical error.
WordPress 6.7.2
Website edited: removed link
bbPress Version 2.6.11
Code Snippets Version 3.6.7