Support

Account

Home Forums ACF PRO Local JSON – can't see fields

Solving

Local JSON – can't see fields

  • I’ve been building a plugin that includes some functionality of ACF-Pro, and I can’t see the fields loaded from a JSON file.

    I created the fields “by hand” on a dev site, exported as a JSON file, and moved that file to a folder in my plugin folder that should load thru this code:

    add_filter('acf/settings/load_json', 'my_acf_json_load_point');
    function my_acf_json_load_point( $paths ) {
        unset($paths[0]);
        $paths[] = plugin_dir_path(__FILE__).'acfjs';
    //var_dump($paths);
        return $paths;
    }

    The var_dump line that’s commented out verified that the path is set properly, but when I go into the back end I don’t see the fields where they should be. (If you must know, this is a repeater field to select users who have access to a custom content type.)

    When this works right, I see my field group in the editing screen for my custom content.. a pull-down menu to select a user, and a corresponding pull-down to select the access privileges.

    Once I got the fields exported to a JSON file from the dev site, I deleted the field group in the back end and put the JSON file into the proper folder, but my content type doesn’t see the fields. To try to put things back together, I tried to reimport the JSON file, only to be told that the field group already exists and will be ignored.

    Does the field group already exist because ACF sees it in the load folder (even though *I* can’t see it)? Or is it because there is something lingering in the database from the (identical) group that I trashed?

    For what it’s worth, when importing the JSON file to another site (after installing my plugin), I didn’t see the fields.. only the header of the metabox where the fields should be. It was only after “editing” and updating the field group in the back end that the field group really showed up.

    Thanks a lot for your attention.

  • It appears to be left-over dreck in the database that’s keeping me from manually importing the JSON file. When I delete the file from the load folder, I’m still prevented from importing (group ignored, already exists).

    If I change the ID key, I can import, and the file shows up in the load directory after I update.

    On the other hand, if I simply add the file to the load directory, it doesn’t load. get_field_objects() returns false.

    Am I missing something, or does this not work the way I think it should?

  • Hi @ObbieZ

    Thanks for all the info.

    You may have stumbled across a bug with this statement:

    
    Does the field group already exist because ACF sees it in the load folder (even though *I* can’t see it)?
    

    I’ll do some testing and get back to you.

    Can you attempt to remove the .json file from your load point folder and then import it? Does the import work if the .json file is not within the load point folder?

  • Hi @ObbieZ

    Just read your second post. Yep, it’s not a bug – feww!

    The import won’t work if you have a trashed field group using the same key (top of json file).

    The get_field_objects() will only return an array of fields if data has been saved on the post. Are you able to successfully use the get_field_object(‘field_name’) in the same template file?

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

The topic ‘Local JSON – can't see fields’ is closed to new replies.