Support

Account

Home Forums ACF PRO Git deploy workflow for ACF Local JSON (Only sync on production) Reply To: Git deploy workflow for ACF Local JSON (Only sync on production)

  • So the first thing is if you will never edit the field groups on the production site then you never need to sync them on the production site. They should not reside in the database at all and the only place they should exist is in the JSON files. The only time the field groups in the DB are loaded is when editing them in the ACF admin.

    If it were a site I was managing I would delete all of the field groups from the DB. This will delete the JSON files. Then upload the acf-json folder back to the site and not sync them.

    There is a value that can be added to each of the JSON files https://www.advancedcustomfields.com/resources/synchronized-json/ you set private to true and this prevents them from being synced.

    Build a plugin on that is installed where you will work on the fields. All I can dgive you is the functions. These are only basic and do not account for any special cases

    
    add_filter('acf/prepare_field_group_for_import', 'acf_private_false', 20, 1);
    function acf_private_false($group) {
      $group['private'] = false;
      return $group;
    }
    
    add_filter('acf/prepare_field_group_for_export', 'acf_private_true', 20, 1);
    function acf_private_true($group) {
      $group['private'] = true;
      return $group;
    }