That wouldn't work for this case.
I have a code that's almost working. It's able to clone every field except for groups.
Here's how it's looking like so far:
// duplicate all post meta
$post_meta = get_post_meta( $post_id );
if( $post_meta ) {
foreach ( $post_meta as $meta_key => $meta_values ) {
foreach ( $meta_values as $meta_value ) {
add_post_meta( $new_post_id, $meta_key, $meta_value );
}
}
}
How could I improve this so it'll also be able to go through the subfields?