Home › Forums › General Issues › Set a field's value to null or other value? › Reply To: Set a field's value to null or other value?
Hi John,
Thank you very much for your advice. I tried the following code unfortunately without luck.. Nothing changes. Im a beginner at this so I was wondering if you or someone else can advice me on what is wrong?
function my_acf_save_post( $post_id ) {
// Bail early if no data sent.
if( empty( $_POST[‘are_we_counting_participants’] ) ) {
return;
}
// Get values.
$values = $_POST[‘are_we_counting_participants’];
// Update with new value.
if( $values == ‘no’ ) {
update_field(‘number_of_participants’, NULL);
}
}
add_action(‘acf/save_post’, ‘my_acf_save_post’);
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.