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

Can't update acf field inside a comment #37

Closed
fabioquarantini opened this issue May 24, 2016 · 6 comments
Closed

Can't update acf field inside a comment #37

fabioquarantini opened this issue May 24, 2016 · 6 comments

Comments

@fabioquarantini
Copy link

fabioquarantini commented May 24, 2016

Hello, thanks for the great plugin.

I have a custom field "rating" which is assigned to every comment,
I can read the value by doing :
GET http://website.com/wp-json/acf/v2/comment/2
and the response is

{
  "acf": {
    "rating": "3"
  }
}

I need to update this value when a user submit a rating and the call looks like this:
PUT http://website.com/wp-json/acf/v2/comment/2
body is form-data
fields[rating] = 4

this is the response i get:

{
  "code": "cant_update_item",
  "message": "Cannot update item",
  "data": {
    "status": 500
  }
}
@airesvsg
Copy link
Owner

Hi @fabioquarantini,
when you edit the field, you are authenticated?
http://v2.wp-api.org/guide/authentication/
Thanks

@fabioquarantini
Copy link
Author

Yes I'm using Basic Auth

@airesvsg
Copy link
Owner

OK, I'll test soon.

@airesvsg
Copy link
Owner

Hi @fabioquarantini,
please put this snippet in your functions.php

add_filter( 'acf/location/rule_match/comment', function(){
    return true;
} );

Thanks

@fabioquarantini
Copy link
Author

It works. Thanks

@ileafsolutions
Copy link

ileafsolutions commented Aug 9, 2016

Hi, Could you help me in editing a notes field of acf. Here is the response which I have when called this http://test.localhost/wp-json/acf/v2/user/279 using the method GET

{
  "acf": {
"notes": [
      {
        "note": "test test",
        "user_id": "3",
        "col1": null,
        "user_name": "siteadmin",
        "col2": null,
        "created_at": "08/05/2016 09:08:55 am",
        "col3": null,
        "modified": "08/05/2016 09:09:39 am"
      },
      {
        "note": "test2 test2",
        "user_id": "3",
        "col1": null,
        "user_name": "siteadmin",
        "col2": null,
        "created_at": "08/05/2016 09:08:55 am",
        "col3": null,
        "modified": "08/05/2016 09:09:40 am"
      }
]

I would like to add another notes. I tried with PUT method and it says

{
  "code": "cant_update_item",
  "message": "Cannot update item",
  "data": {
    "status": 500
  }
}

I have tried via postman.Its would be great if you could help me on this.

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

2 participants