Home › Forums › Backend Issues (wp-admin) › Update a field when duplicating a post › Reply To: Update a field when duplicating a post
Ok, I figured out that this could be achieved by resetting the value to false (no) after a product is published. That way the duplicate is loaded with No selected.
This code works, but please let me know if I can improve upon it. Thanks.
function reset_product_readiness_after_publish( $post_id ){
$value = "0";
update_field('field_30705432c7518', $value, $post_id);
}
add_action('acf/save_post', 'reset_product_readiness_after_publish', 20);
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 Privacy Policy. If you continue to use this site, you consent to our use of cookies.