Skip Navigation

[Closed] Update toolset meta data via the rest api

This support ticket is created 2 years, 11 months ago. There's a good chance that you are reading advice that it now obsolete.

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.

This topic contains 2 replies, has 2 voices.

Last updated by Nigel 2 years, 11 months ago.

Author
Posts
#2275045

Tell us what you are trying to do?
I have a custom type called 'transactions' which has two custom fields. I can add transactions via the rest API but I don't know how to set the values for the custom fields.

Is there any documentation that you are following?

Is there a similar example that we can see?

What is the link to your site?

#2275053

Here is the ajax code I am using at the moment.

me.postIt = function() {
var jsondata = JSON.stringify({
title: 'Daniel Whittaker',
'toolset-meta': {
'transaction-data': {
value: 4.25,
VIPID: 160
}
},
status: 'publish'
});
jQuery.ajax({
type: "POST",
contentType: 'application/json',
url: 'hidden link',
data: jsondata,
beforeSend: function ( xhr ) {
xhr.setRequestHeader( 'X-WP-Nonce', tve_frontend_options.nonce );
},
success: function (data) {
alert("posted");
},
error: function (error) {
alert("FAILD:" + error);
}
});

};

#2275145

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Hi Daniel

Toolset includes a very limited integration with the REST API, which allows you to include formatted custom field values in REST responses in a special property "toolset-meta".

See this document for details: https://toolset.com/documentation/programmer-reference/toolset-integration-with-the-rest-api/

There is no support for writing to Toolset custom fields.

But. Toolset custom fields are stored as standard post meta, and so you can use the normal WordPress REST API to store custom fields.

Explore the official handbook to learn more: https://developer.wordpress.org/rest-api/

(There are also lots of tutorials online if you search.)

Just bear in mind that Toolset custom fields are stored in wp_postmeta with a 'wpcf-' prefix, so if you have a 'priority' custom field its slug would be 'wpcf-priority'. Also, most custom fields store a simple raw value (again, if priority was a select field with option and label combinations of "One":1, "Two":2, "Three": 3 etc., and a post had priority Two selected, then the value stored (or that would need storing) in wp_postmeta for wpcf-priority would be '2'.

The topic ‘[Closed] Update toolset meta data via the rest api’ is closed to new replies.