Support

Account

Forum Replies Created

  • @john-homenuke, Got it. Your method sounds like a solid approach which is the same approach I took. I just got tripped up on those brackets. I take it lots of people use that approach. I’m surprised I’m the only one (I could find) that experienced the issue with the brackets.

    So instead of suggesting that ACF remove the brackets from export I suggest that ACF understand the brackets when loading. Apparently ACF understands them on import.

    Thanks!

  • I discovered the issue…

    I didn’t manually create the field group I wanted to load via my plugin. I created it using ACF then exported it. When you export json from the ACF interface it includes a opening bracket at the top and a closing bracket at the bottom. See my exported json code above. These brackets need to be removed if you intend to use the json file for loading. I removed those brackets and it works.

    Wow. I suggest that ACF does not include those brackets on export.

    I hope others can benefit from my turmoil.

    Thanks to @beee and @john-homenuke for your input.

  • Hey @john-homenuke. I did not create the json myself. I can import the json using the ACF interface. And after importing the json file I do see the field group at the correct location (any page post type). So that json file works.

    Besides ACF Pro and my plugin there are no other active plugins.

    ACF doesn’t have a save location for field groups? Hmm. Well I instructed ACF to save the json file for field groups to a folder within my plugin using add_filter('acf/settings/save_json' and that worked. Despite this feature not being directly related to the loading of json I wanted to test it to just ensure at least it worked.

    I understand it wouldn’t save any loaded groups because you can’t see the loaded json/field groups in the interface. I had other field groups available in the interface. When they were saved ACF saved them to the folder I set.

    It’s an odd thing. This is a pretty simple implementation, very little code, in a very simple setup, nothing unique, etc. It has to be something absurdly obvious or some tiny detail that’s alluding me, but I can’t imagine what. I’m out of ideas. I even tried this same setup on a different website. Nothing. It will not load the json from the folder I set.

  • Hi @john-homenuke. Thanks for the reply.

    I set the priority to 20. That did not do the trick, unfortunately.

    I reconfirmed the path to the json directory is correct. I confirmed that chmod is 755 for the json directory. There is no plugin interference (no other plugins except ACF PRO and my little plugin here are active). The json file does work when imported using the ACF interface. For the heck of it I tried the acf/settings/save_json feature which allows you to save to a set directory. That works fine. There’s nothing unique about my case. Hmm. I’m stumped.

    It does make me wanna confirm this hook is firing at the correct time. How can I ensure it’s not firing after ACF has been initiated? Right? That would be an issue to resolve although I suspect it’s not the case here being that this is the only thing loading on my plugin and there are no other plugins active. Hmm.

  • Thanks for the reply @beee. I confirmed the path to the directory is correct. Hmm. I’ve just hit a wall. How can I confirm the add_filter is firing when it should? What else could the issue be?

  • Hello all. I understand this topic seems closed, but I’m hoping you folks can help me resolve this. I want to load my field group json file which lives in a folder within my plugin. Let me explain my setup.

    There are only two active plugins, ACF and my very simple custom plugin (which only attempts to load a json field group).

    Here’s a look at the .json file. Super simple for testing purposes. And this works if I build it out in the ACF interface. It displays on every page. I exported this group’s json and removed it from the ACF interface. So at this point you don’t see this group in ACF.

    [
        {
            "key": "group_63bc2ff8023f5",
            "title": "Test Field Group",
            "fields": [
                {
                    "key": "field_63bc2ff682571",
                    "label": "Test Message",
                    "name": "",
                    "aria-label": "",
                    "type": "message",
                    "instructions": "",
                    "required": 0,
                    "conditional_logic": 0,
                    "wrapper": {
                        "width": "",
                        "class": "",
                        "id": ""
                    },
                    "message": "If you're on a page you should see me. Do you?",
                    "new_lines": "wpautop",
                    "esc_html": 0
                }
            ],
            "location": [
                [
                    {
                        "param": "post_type",
                        "operator": "==",
                        "value": "page"
                    }
                ]
            ],
            "menu_order": 0,
            "position": "normal",
            "style": "default",
            "label_placement": "top",
            "instruction_placement": "label",
            "hide_on_screen": "",
            "active": true,
            "description": "",
            "show_in_rest": 0
        }
    ]

    I placed the following code in my main plugin file.

    
    add_filter('acf/settings/load_json', function($paths){
      $paths[] = WP_PLUGIN_DIR .'/gmr-ssp/acf-json';
      return $paths;
    });

    Uploaded everything. Refresh. Nothing. It does not load the field group on the page. The following DOES run and prints the correct paths to the folder where my field group json file resides.

    add_filter('acf/settings/load_json', function($paths){
      $paths[] = WP_PLUGIN_DIR .'/gmr-ssp/acf-json';
      print_r($paths);
      die();
      return $paths;
    });

    I just don’t see what I’m missing here.

    Any insight would be greatly appreciated.

    Thanks!

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