airesvsg / acf-to-rest-api

Exposes Advanced Custom Fields Endpoints in the WordPress REST API
https://wordpress.org/plugins/acf-to-rest-api/
1.33k stars 111 forks source link

Edit Custom Field Group select options via Rest API #405

Open prononext opened 2 years ago

prononext commented 2 years ago

Dear airesvg,

I want to edit the select options inside a ACF field group via Rest API.

My ACF fields are linked to the product post-type.

I tried the following via Postman:

POST: https://example.com/wp-json/acf/v3/product/IDOFTHEFIELDGROUP

also tried: POST: https://example.com/wp-json/acf/v3/product/IDOFTHEFIELDGROUP/NAMEOFTHEFIELD

with body and/or query: { "key": "field_633ee9a8333fc", "label": "testselect", "name": "testselect", "type": "select", "choices": [ "red", "blue" ], "default_value": "", "allow_null": "1", "multiple": "0" }

or: { "choices": [ "red", "blue" ] }

Sadly none of them worked.

Also if I do a:

GET: https://example.com/wp-json/acf/v3/product/IDOFTHEFIELDGROUP/testselect

I get:

`[
{
"testselect": null
}
]`

Something seems to be wrong as all other standard wordpress Rest API Calls are working ok. Also filling the custom fields inside a existing post / product or any other doctype is no problem.

I also edited the functions.php with the options you gave in the readme, and activated them accordingly:

`/ Enable the option show in rest
add_filter( 'acf/rest_api/field_settings/show_in_rest', '__return_true' );

// Enable the option edit in rest
add_filter( 'acf/rest_api/field_settings/edit_in_rest', '__return_true' );`

No success.

Please help. I am also willing to support this project further if its functionality is working for me.

Thank you Have a nice day