Hello ,
Searched all over and couldn’t find an answer .
Q : How to change the state ( update ) a true / false field. I tried :
update_field('topic_solved', array('solved' => "solved"), 4237)
update_field('topic_solved', true, 4237)
update_field('topic_solved', 1, 4237)
update_field('topic_solved','1', 4237)
and all these with ‘field_44’ instead of ‘topic_solved’ .
Note: field_44 is the field key .
Please advise ,
thanks in advance.
Hi @toleanu
The true/false field will save it’s data as either a 1 or a 0. So the code update_field('topic_solved', 1, 4237)
should work correctly.
If the post (4237) does not already contain a value, you must use the field_key instead of the field name, however, it looks like you have already tried this.
Perhaps the code is not running due to a PHP error before it?
Thanks
E
Thanks , I got it fixed – it was an error from my code . Sorry for bothering you .