Home › Forums › General Issues › Local JSON vs. Register via PHP vs. WP Database
I have broken things in my multisite network and I’m pretty sure it’s connected with my having tried to switch to registering my field groups via PHP in my custom plugin after having done most of my development using a local JSON folder inside the plugin.
I am wondering how each method (local JSON, register via PHP, and create via the ACF UI in WP admin) affect the database. Could I have conflicting info about the field groups in the database that is causing problems?
The errors I am getting in the WP dash include:
I realize not all of the above may be related to ACF, however, all the above go away when I disable my plugin. I suspect that #2, #3 and #4 above are consequences of the server timing out with whatever is causing #1.
Of possible significance: when I initially switched my plugin from pointing to its non-standard JSON save and load location, I rediscovered the acf-json folder in my theme.
The reason I tried to switch to registering via PHP after developing with a custom acf-json folder in my plugin was that another plugin, Network Posts Extended, running on my main site, would only display ACF field content if I manually synced the ACF field groups on each and every subsite. (I wanted to avoid having to log into 90 or so subsites to do this, and to avoid needing to remember to do it on future subsites.)
All of your issues look to me like there is a php error during AJAX requests that is causing the request to fail “The response is not a valid JSON response.” The first step is to turn on debugging and error logging, check your error log and clear up any php errors and warnings if there are any.
meant to post a link to WP_DEBUG https://codex.wordpress.org/WP_DEBUG
Some poorly commented out code seems to have been the culprit. It wasn’t throwing any debug statements, but I discovered when deactivating / activating the plugin, the WP dash would display a message about my plugin producing 72 “unexpected” characters. That was as precise as it got.
I would still *like* to know why I can’t seem to get my fields to be 100% functional across the network without using local JSON and manually synching at each subsite, but I can move forward for now.
If you put your field groups into PHP and the file is loaded by all sites then they will work on all sites.
JSON files should work on all sites if they are loaded by all sites and syncing should not be needed. I have a couple of site in multisite that use JSON files. Not only do I not sync the groups to all sites, but they don’t even exist in the DB for sub sites, only the main site. All of the sites use the same theme so any changes I make to the field groups are automatically reflected in the sub sites. The only place the DB version of any site is used is when you edit the field group. Under all other conditions, if the field group exists as json then the json will be loaded.
You must be logged in to reply to this topic.
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!
🚨 The 2023 ACF Annual Survey closes tomorrow! This is your last chance to complete the survey and help guide the evolution of ACF. https://t.co/0cgr9ZFOJ5— Advanced Custom Fields (@wp_acf) May 18, 2023
© 2023 Advanced Custom Fields.