I have a group of ACF number fields on an Options page for basic automatic calculations. All field values (entered and calculated) are then output to pages/posts using ACF shortcodes. Everything works great…until I add an acf/format_value function to format all numbers with commas. My understanding is that ACF/format_value only runs on the front end of the website. However, once my function is enabled, my calculated fields on the Options page are incorrect. I have a feeling I am missing something very basic – any suggestions are greatly appreciated.
The issue is that the function to format the value is being used when you use get_field in your save post action. This means that the calculation is attempting to do the the calculation with formatted value.
To overcome this you need to tell ACF not to format the values. This is done by adding the 3rd argument to get_field(), example:
John – I cannot thank you enough. You sir, are a rock star. I had a feeling that ACF was formatting the values, but was not aware of the 3rd argument to disable (inexperience on my part). I just updated my code and everything is working great. Best wishes to you!
Viewing 3 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users