Home Forums ACF PRO Database sync of all sites in network? (based acf-json files)


Database sync of all sites in network? (based acf-json files)

  • Hello,

    I’m using the JSON ACF approach to store information about fields.

    This is being used on a single theme, which is used across multiple sites in the same network.

    The problem is, whenever I make changes to ACF setup (on my local dev machine), and sync the theme files (including ACF JSON files) up to remote, I would then have to go to each site in the network and run the sync operation manually.

    Fields are 100% the same across all the sites and there won’t be any deviation in the future.

    Is there a way to just have a single button, that I would click and script would go over all sites in the network and perform the ACF JSON sync for all the fields that need to be updated? Basically, turn the manual operation of going to each site and syncing, into a semi-automatic one, when I just do that on a network level?

    I’m fine with writing some kind of plugin or something custom, but honestly, I’m not even quite sure where to start.

    I would imagine it would look something like…

    – iterate over the sites in network
    – inside each site, get a list of acf groups (from json?…) and see which need to be updated ( how? function names?… what if a new field group was added – how to detect this new json file? it is automatic?… )
    – and eventually run the sync operation ( again, which functions to use?… )

    I checked all the plugins I could find here, but they either seem not to be updated for a long time or just way to complex for the task.

    Or am I going things wrong? I definitely would like not to export and import PHP, because this is pretty error-prone, and will puzzle the end-user who will be maintaining this in the future.

    So really… just a single button, going over all network sites, and checking/syncing if ACF JSON data is in sync with database data.

    Help, or directions? Please?

  • There is a topic here that appears to have a solution for auto syncing

    That being said, I’m not sure I’d worry about it. I currently have a multisite install where I have the same situation. The same theme and ACF fields are used on all sites. Not only this, but I have to “dev” copies of this multisite install. When I make changes on one site I then sync all of the files, like you. But then I don’t bother syncing the ACF fields, this is not necessary as the JSON files will be used and override what is in the database. The next time I work on a site, if I need to make changes to the fields, I sync the field groups for the site I and group I am currently working on. If the client was going to take over this, I would assume that they are capable to doing this as well.

  • OMG. Thank you so much John!

    I didn’t realize JSON files actually take precedence over database. I just for some reason decided that if the sync is there, it needs to be performed in order to apply changes. Literally performing facepalm on my side… 🤦‍♂️

    Thanks again!

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

The topic ‘Database sync of all sites in network? (based acf-json files)’ is closed to new replies.