Support

Account

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’);