Home › Forums › General Issues › Check a taxonomy radio field in ACF Save Post › Reply To: Check a taxonomy radio field in ACF Save Post
Can you give me a link to this other question I answered?
At this point I can only say what I would do.
When adding the taxonomy field in ACF there are settings for saving and loading terms, I would turn both of these on.
function my_acf_save_post_function($post_id) {
// get the value of the first taxonomy field
// I am getting it unformulated
// which means that it's returning an array of term IDs
// you might do this differently depending on what you want to do
get_field('other_tax_field', $post_id, false);
// check this field for whatever condition you are looking for
if ($condition) {
// get the value of the field you want to change
$other_field = get_field('the other field', $post_id, false);
// append a term ID value to the value
// if it does not already exist
if (!in_array($new_term_id, $other_field)) {
$other_field[] = $new_term_id;
}
// update acf field
// acf will take care or updating terms because of the settings
update_field('the other field', $other_field, $post_id);
}
}
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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.