I have added post meta to my CPT.
In that CPT i have also ACF that add fields to this CPT.
I also used the hook save_post{post_type} so that when my CPT is updated, meta is added to that post.
My problem is that the ACF data is saved AFTER the add_post_meta function runs and i need the add_post_meta to use fields from the ACF so i need the ACF to run first, then the add_post_meta function will get it's values acording to calculations by these ACF fields.
the code i used is:
add_action( "save_post_car", "save_posts_meta_values", 999999, 1 );
function save_posts_meta_values( $post ){
if ( get_post_type( $post ) == 'car' ) {
$post_id = get_the_ID();
$my_values = array(
'front' => 5,
'back' => 6,
'right' => 7,
'left' => 8,
'engine' => 9
);
update_post_meta( $post_id, 'total_values', $my_values );
}
}
can't come up with a proper solution to my problem.
i have searched through the stackoverflow website to find similar questions but the didn't come up with the solution to my problem.
please help :) thank you!