pods icon indicating copy to clipboard operation
pods copied to clipboard

Custom fields not updating via REST API

Open sc0ttkclark opened this issue 1 year ago • 15 comments

Seems like it still doesn't work. Meta data fields i POST through the WP API remain empty. Whether i set "Allow All Fields To Be Updated" or allow one by one on field level. Should i raise a new issue for this?

Originally posted by @kilianso in https://github.com/pods-framework/pods/issues/7318#issuecomment-2232900895

sc0ttkclark avatar Jul 17 '24 14:07 sc0ttkclark

Hi there! Any workaround while 3.2.6 is out?

miguelomonroyb avatar Jul 19 '24 19:07 miguelomonroyb

Trying to get this into Pods 3.2.6 for release tomorrow.

sc0ttkclark avatar Jul 21 '24 20:07 sc0ttkclark

https://github.com/pods-framework/pods/pull/7329

sc0ttkclark avatar Jul 21 '24 20:07 sc0ttkclark

If anyone has time before tomorrow's release, I'd appreciate you trying Pods 3.2.6 out and letting me know if that resolves the write issues you're having.

release/3.2.6 https://github.com/pods-framework/pods/archive/refs/heads/release/3.2.6.zip

sc0ttkclark avatar Jul 21 '24 20:07 sc0ttkclark

To help address the issue here, I added some automated testing coverage for it to help ensure long term stability.

sc0ttkclark avatar Jul 21 '24 20:07 sc0ttkclark

If anyone has time before tomorrow's release, I'd appreciate you trying Pods 3.2.6 out and letting me know if that resolves the write issues you're having.

release/3.2.6 https://github.com/pods-framework/pods/archive/refs/heads/release/3.2.6.zip

I just installed it, I let you know if It works or if anything else is required

miguelomonroyb avatar Jul 22 '24 13:07 miguelomonroyb

@miguelomonroyb any luck?

sc0ttkclark avatar Jul 22 '24 14:07 sc0ttkclark

@sc0ttkclark I just quickly tested it on a stage environment using 3.2.6-a-1 and the issue persists for me. The data i POST looks something like this:

data: { status: 'draft', title: 'ABC' meta: { origin_url: 'abc.com' } }

I'm hitting the endpoint /wp-json/wp/v2/myCPTname

The field 'origin_url' remains empty. 'title' and other non-meta fields are submitted and saved correctly.

I tried each settings combination. "Allow All Fields To Be Updated" activated/deactivated and "Read/Write via REST API" activated/deactivated on field level.

kilianso avatar Jul 22 '24 15:07 kilianso

Since you're using the meta level field saving, I'll look at this a bit further from that side.

sclark3-godaddy avatar Jul 22 '24 15:07 sclark3-godaddy

Same here, I'm using the meta level field saving and still the issue persists

miguelomonroyb avatar Jul 22 '24 16:07 miguelomonroyb

To confirm, you have the "Register meta fields" option enabled in your Pods Admin > Settings, correct?

sclark3-godaddy avatar Jul 22 '24 16:07 sclark3-godaddy

I just enabled it, I will try it again

miguelomonroyb avatar Jul 22 '24 17:07 miguelomonroyb

I'm releasing Pods 3.2.6 in the meantime, I can work more on this for Pods 3.2.7 but this release has to go out to address the bigger issue that impacted those using WP 6.5 and below.

sc0ttkclark avatar Jul 22 '24 18:07 sc0ttkclark

@sc0ttkclark I made a few tests and think I've narrowed down the issue. It seems related to the REST API settings here: Pods Admin > Edit Pods > CPTNAME > REST API.

  1. Submitting the metadata flat rather than inside a meta object resolves the issue, but only if the setting "Show as a custom object field (response.field_name)" is active, rather than "Include in the meta object (response.meta.field_name)". If the latter is chosen, neither submitting flat nor as a meta object will update the fields.
  2. The global setting "Allow All Fields To Be Updated" seems broken. Allowing read/write access on the field level, however, works.

I'm on WordPress 6.6 and Pods 3.2.6.

kilianso avatar Jul 23 '24 08:07 kilianso

@kilianso Could you also verify #7339 and let me know if it works for you?

JoryHogeveen avatar Aug 22 '24 10:08 JoryHogeveen