Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Value get's updated, but new keys are not added in JSON response #394

Open
Sandstedt opened this issue Nov 3, 2021 · 6 comments
Open

Value get's updated, but new keys are not added in JSON response #394

Sandstedt opened this issue Nov 3, 2021 · 6 comments

Comments

@Sandstedt
Copy link

Sandstedt commented Nov 3, 2021

For some weird reason (not sure if it's related to this great plug-in, or some server setup), suddenly (it did work before) new changes in ACF (adding new fields) doesn't show up in the JSON output.

So ex: I have a flexible content array with some components inside (acf_fc_layout). When I add a new component there with some fields in, the only thing showing up in the REST API JSON response is acf_fc_Layout: "name_of_component". No other fields are visible.

But on older components that has many key value pairs already, I can change the content and the value will update. So it's not a cache issue with the entire JSON file. And everything looks perfectly fine in wp-admin, and I think it looks correct in the DB as well. But a bit hard to know.

So seems to be something wrong between the DB and ACF to REST API plug-in and how that returns the JSON response.

Any idea how to debug or finding the root cause of this weird issue?

Ex response:
(replace [slash] with / in url:s, just making it hard for bots here on github :D)
/wp-json/preview/v1/1419 -> acf -> fields[2]. Here there should be a isBookingZone: true, that is visible and working in both WordPress and the database, but it is not showing up here in the response. But changing title returns correct value.
bild

Also attaching the ACF setup for this category_grid_artists component

bild

@Sandstedt
Copy link
Author

Just gonna note that adding fields to non-flexible content fields seems to work. Just added fields to an options page with a plain hierarchy, and that worked just fine. Will try to investigate a bit more. But a bit hard when I don't know how everything is connected among pages and meta data.

@danimalweb
Copy link

I am having a similar issue. I am not using Flexible fields.

@Sandstedt
Copy link
Author

@danimalweb
We ended up exporting the fields to a JSON file, deleted the ACF declarations, changed the root id to another random id in the JSON file, and then imported it again. Then it "just worked". But a cumbersome workaround. So will leave this open. But the example URL's in this issue will now work correctly, so have removed them.

@fringley
Copy link

I think I am experiencing the same issue, though mine is with a custom field group that was added to users.

Whilst the values on these fields appears to be persisted (from some business logic when a user registers), none of the values make it into the JSON response until I go in and edit them manually (or re-save the account) from within WP Admin.

I've included two screenshots, one which shows how many lines present in the JSON response before re-saving the account (175 lines) and the second one after saving (178 lines).

Strangely, in the ACF group, one of the fields does come through every time - it only seems to be a recently added fields that are not appearing. Also other ACF groups work perfectly all the time.

less-fields

more-fields

I would love to help track down this issue and work on a fix - as it is really affecting the operation of my site (as I need to go in and re-save every new user!)

@fringley
Copy link

fringley commented Jun 7, 2022

Hi @airesvsg Any idea about this - it's causing me huge issues with using this plugin as some fields are missing on the API, even though there are values set on the user object!

@fringley
Copy link

fringley commented Jun 7, 2022

Was doing some further investigation today... It seems that all ACF fields are being returned if I use the WooCommerce API
... e.g. https://DOMAIN/wp-json/wc/v3/customers/600 is correctly displaying the field within the meta_data section of the response.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants