Home › Forums › ACF PRO › update_field() returning FALSE if value to update is not changed… › Reply To: update_field() returning FALSE if value to update is not changed…
I can understand your frustrations a bit, but I can also guess to some degree the developer’s thinking is that it works consistent with the way update_post_meta() works and update_field() is just a wrapper for update_post_meta().
Returns meta_id if the meta doesn’t exist, otherwise returns true on success and false on failure. NOTE: If the meta_value passed to this function is the same as the value that is already in the database, this function returns false.
Maybe when he gets time he’ll add it to the documentation. I’m also assuming that since update_field() does not mention returned values that it’s not expected that anyone would be testing the returned value. The function is not going to “Fail”, after it is called the field value for the post_id will be set to you want to update it to, one way or another.
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!
❓Ever wondered when and why ACF uses JSON instead of the database? Check out our summary of the most recent session of ACF Chat Friday for the answer, and make sure to register for the next session.— Advanced Custom Fields (@wp_acf) February 23, 2023
© 2023 Advanced Custom Fields.