Home › Forums › General Issues › Issue with Update_Value › Reply To: Issue with Update_Value
Hi,
I’ve managed using save_post :
function my_acf_save_post_6 ($post_id) {
$reviews_of_post = get_posts( array(
'post_type' => 'ratings',
'meta_query' => array(
array(
'key' => 'product',
'value' => '"' . get_the_ID() . '"',
'compare' => 'LIKE',
),
),
) );
foreach ( $reviews_of_post as $review ) {
$rating_sum += get_field( 'single_rating', 'post_' . $review->ID);
}
$value = $rating_sum/count($reviews_of_post);
// do something
update_field('field_5de8d2cf1b919', $value, $post_id);
}
add_action('acf/save_post', 'my_acf_save_post_6', 20);
My only issue now, is that I have to go to my Product post and I still have to update in order to see the rating.
How can I “auto-update” the value without needing to re-publish ?
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.