pods-framework / pods

The Pods Framework is a Content Development Framework for WordPress - It lets you create and extend content types that can be used for any project. Add fields of various types we've built in, or add your own with custom inputs, you have total control.
https://pods.io/
GNU General Public License v2.0
1.06k stars 266 forks source link

Custom fields not updating via REST API #7327

Open sc0ttkclark opened 1 month ago

sc0ttkclark commented 1 month ago

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

miguelomonroyb commented 1 month ago

Hi there! Any workaround while 3.2.6 is out?

sc0ttkclark commented 1 month ago

Trying to get this into Pods 3.2.6 for release tomorrow.

sc0ttkclark commented 1 month ago

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

sc0ttkclark commented 1 month ago

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 commented 1 month ago

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

miguelomonroyb commented 1 month ago

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

sc0ttkclark commented 1 month ago

@miguelomonroyb any luck?

kilianso commented 1 month ago

@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.

sclark3-godaddy commented 1 month ago

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

miguelomonroyb commented 1 month ago

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

sclark3-godaddy commented 1 month ago

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

miguelomonroyb commented 1 month ago

I just enabled it, I will try it again

sc0ttkclark commented 1 month ago

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.

kilianso commented 1 month ago

@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.

JoryHogeveen commented 2 weeks ago

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