You should be able to do this by using the update_field() function. It should be something like this:
<?php $field1 = floatval(get_field('falt_1','user_'. $curauth->ID)); $field2 = floatval(get_field('falt_2','user_'. $curauth->ID)); $field3 = floatval(get_field('falt_3','user_'. $curauth->ID)); $total = ($field1 * $field2) * $field3; update_field('mojlig_besparing', $total, 'user_'. $curauth->ID); echo '<h3>Fält1: '.$field1.'</h3>'; echo '<h3>Fält2: '.$field2.'</h3>'; echo '<h3>Fält3: '.$field3.'</h3>'; echo '<h2>Totalt:' .$total.'</h2>'; ?>
Please keep in mind that the value will be saved when you open the page. If you want to save it when along with the other fields, kindly use the acf/save_post hook instead.
I hope this helps 🙂
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!
ACF PRO’s Flexible Content field allows you to create smaller pieces of UI and compose them into whole flexible patterns. In our latest article, we show how to use it to create swappable site sections and integrate it all in a theme.https://t.co/ZRocH8oJSp— Advanced Custom Fields (@wp_acf) January 24, 2023
© 2023 Advanced Custom Fields.