Support

Account

Forum Replies Created

  • I’ve managed to get it working using your code as a starting point. This is my first try at anything plugin related so there might be a better/cleaner way to do it, or things I haven’t considered.

    I have 2 ACF field groups

    • group_5d9700e0b69a7 – related to my theme and saves/loads/syncs from my-theme/acf-json folder
    • group_5d921d2978e9e – related to my plugin and saves/loads/syncs from my-plugin/acf-json folder
    /********************************/
    // Save and load plugin specific ACF field groups via the /acf-json folder.
    /********************************/
    
    // Save
    function my_plugin_update_field_group($group) {
      // list of field groups that should be saved to my-plugin/acf-json
      $groups = array('group_5d921d2978e9e');
    
      if (in_array($group['key'], $groups)) {
        add_filter('acf/settings/save_json', function() {
          return dirname(__FILE__) . '/acf-json';
        });
      }
    }
    add_action('acf/update_field_group', 'my_plugin_update_field_group', 1, 1);
    
    // Load - includes the /acf-json folder in this plugin to the places to look for ACF Local JSON files
    add_filter('acf/settings/load_json', function($paths) {
      $paths[] = dirname(__FILE__) . '/acf-json';
      return $paths;
    });
  • Should the above code go into my main plugin php file?

    I have tried adding it and updating a single group id to the array which seems to allow all the field groups to be saved into my-theme/acf-json apart from the group id listed which I believe is correct.

    The bit that doesn’t seem to be working is the group id added to the array that I want to be associated with my plugin isn’t being saved into the my-plugin/acf-json folder, it isn’t actually getting saved anywhere.

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