Skip Navigation

[Resolved] Can't update CPT through API

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 3 replies, has 2 voices.

Last updated by Minesh 3 months, 3 weeks ago.

Assisted by: Minesh.

Author
Posts
#2751659

Tell us what you are trying to do?
Run a PUT to update a CPT made in Toolset. Postman returns 200 OK. Post modified date changes, but no other data does.

Is there any documentation that you are following?
I read this:
https://toolset.com/forums/topic/update-cpt-custom-fields-via-rest-api/
And was wondering if this might be the issue. If so I need clarity on his statement, "You will need to use the native WordPress functions to access the fields and update them like any other native custom WordPress field."

Here is the JSON body I am sending:

{
"id": 4608,
"toolset-meta": {
"field-group-for-dealers": {
"business-name": {
"type": "textfield",
"raw": "5 Star Custom Portable Buildings!!!!"
},
"tsa-store-id": {
"type": "numeric",
"raw": "1188"
},
"main-phone": {
"type": "phone",
"raw": "(205) 339-3518"
},
"address": {
"type": "google_address",
"raw": "6602 McFarland Blvd, Northport, Alabama, 35476"
},
"email": {
"type": "email",
"raw": "aaaaaamike.woodard@hotmail.com"
}
}
}
}

What is the link to your site?
I have tested this on the following endpoints:
hidden link
hidden link

#2751667

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Toolset integration with REST API is limited and offers the GET callback where custom fields are exposed to REST API callback response:
=> https://toolset.com/documentation/programmer-reference/toolset-integration-with-the-rest-api/

You will require to define the endpoint to register the update callback function for the user meth.

Please check the following related link:
- https://wordpress.stackexchange.com/questions/338134/updating-custom-wordpress-user-meta-field-via-rest-api

Please check the following related ticket:
- https://toolset.com/forums/topic/update-toolset-meta-data-via-the-rest-api/#post-2275145

#2751714

Thanks for the info Minesh. I read them and I think I understand. I'm quite new to all this. It seems like this should be a feature native to Toolset. Is there a technical reason why these fields can't be registered and writeable directly from Toolset? I believe other plugins in this vein provide this functionality, don't they? Are there any plans to add this ability to Toolset?

EDIT: Since I am not a programmer and this required a developer's touch I almost gave up on Toolset, but decided to try ChatGPT. After a little trial and error I was able to generate a PHP script for WordPress that fixed this issue.

#2754447

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Glad to know that you are able to configure the REST API hook. You are welcome to share the solution here so other users can benefit from it.

#2755632

I generated a PHP script for my functions.php file that did what the links above said to do. What I wound up with was highly customized to my needs. I also had to go through the process of learning, in general, how the WP API works, especially with CPTs, which was not as easy as it sounds. It was a long process and I don't know if I can explain it well enough to be beneficial to someone else. I will say that AI was able to guide me through that learning process much faster than Googling it. I honestly think that Toolset should consider making this an easier process for their customers.