add_action('save_post_profile', 'voxel_sync_profile_names_to_user_meta', 20, 3);
function voxel_sync_profile_names_to_user_meta($post_id, $post, $update) {
// Avoid autosave/update loops
if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) return;
if (wp_is_post_revision($post_id)) return;
// Make sure we're targeting the right post type
if ($post->post_type !== 'profile') return;
// Get the associated user ID from Voxel's system
$author_id = get_post_field('post_author', $post_id);
if (!$author_id) return;
// Get custom field values from Voxel (replace with correct field keys)
$first_name = get_post_meta($post_id, 'vx_first_name', true);
$last_name = get_post_meta($post_id, 'vx_last_name', true);
// Update the WordPress user meta
if (!empty($first_name)) {
update_user_meta($author_id, 'first_name', $first_name);
}
if (!empty($last_name)) {
update_user_meta($author_id, 'last_name', $last_name);
}
}