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


Git deploy workflow for ACF Local JSON (Only sync on production)

  • Hey,

    I recently tried out ACF Local JSON, really great feature idea!

    My goal is:

    1. Devs only edit field groups on local development
    2. ACF creates the changed .json files, devs commit it to the git repo
    3. We pull the latest git files on production

    And here is the part which I haven’t figured out:

    4. On production, we only let ACF sync these committed changes

    We don’t want anyone (including admins) to edit field groups on production site in the WordPress dashboard. This should only be done in local development.

    How can I achieve this? Is there something like a “Only show a sync button in dashboard”-option or is there maybe auto-sync available?

    Thanks very much in advance!

    Best regards,
    PS: Found this article

  • 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 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;
  • Thanks so much for providing guidance and your reply! *thumbsup*

    It seems that I don’t really understand the sync feature yet. I thought by uploading a modified json file a sync is required to update the field groups on the live site.

    I’ll will experiment with adding “private:true” and run some tests, thanks again!

    (If anyone knows a small tutorial for this, I’d be really grateful ;-)).

  • PS: I just saw another post I missed earlier. Quite confusing that there are so much possible data states! 😮

  • The point is that if you will not edit the fields on a site then the only thing you need is the JSON files. They only need to be synced to the DB if you need to edit them. I don’t generally worry about what version is being used because I have dev servers where I do all the modifications. The only exception to this is custom fields created for a specific site. I use parent/child themes as well. The field groups for the theme are in the parent. The field groups specific to the site are stored in the child theme’s acf-json folder.

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.