Home Forums Bug Reports Hidden fields when editing a post are not saved Reply To: Hidden fields when editing a post are not saved

  • This is not a bug, but the intended operation.

    When a field is conditional and it does not appear, that fields value is not changed. It is not changed because the field in not submitted.

    ACF does not look at field 1 to see if the conditions are met when saving field 2. The condition is on field 2. ACF has no idea when a field is save what other fields might be conditional base on the value of the field being saved.

    In your template code you need to do the work something like this.

    if (get_field('field#1') == 'A) {
      echo get_field('field#2');

    There have been many discussions on these forums about this. Some like this, some do not. With the way it operates, if a user changes the value and saves the post, if they should change their mind later then the value entered into field 2 will not need to be re-entered.

    The only way around this is to create an acf/save_post filter

    add_filter('acf/save_post', 'my_save_post_function_name');
    function my_save_post_function_name($post_id) {
      if (get_field('field#1', $post_id) != 'A') {
        delete_field('field#2', $post_id);