Home › Forums › General Issues › How to auto sync json acf groups in multisite network? › Reply To: How to auto sync json acf groups in multisite network?
I’ve done this is the past. What you need to do is test to see if the field group exists before importing and it also helps to do the importing only on theme activation.
I actually gave up on this. I keep a dev version of all my themes on a single multisite installation where I do work. I commit changes to all of these themes to github and I use github updater to allow updating the themes on any sites where they are installed.
I don’t have the code any more, I found one filter left in one theme
add_action('after_switch_theme', '_ssi_theme_activation');
function _ssi_theme_activation() {
add_action('admin_init', 'acf_auto_import_groups');
}
So basically, if I remember right, on theme switch I added an admin_init action. In that function I used acf_get_field_groups()
to get all of the existing field groups. Then I read through the acf-json folder and looked for field groups that did not already exist to import.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.