Contents
On this page
Save Custom Fields - Plugixa Stream
PUT /plugixa-stream/v1/admin/custom-fields
Replace the whole list of custom fields. The order you send is the order everywhere.
Needs a user with the plugixa_stream_manage_settings capability (signed in with an Application Password or the login cookie). Administrators hold it; other roles only when you grant it.
Note. A field whose key changes no longer shows its old values; they stay stored until uninstall.
Request
PUT https://your-site.example/wp-json/plugixa-stream/v1/admin/custom-fields
Request body
Content type: application/json
| Field | Type | Required | Description |
|---|---|---|---|
fields |
object[] |
Yes | Every definition. Each field’s keys are those of List Custom Fields. |
fields[].key |
string |
Yes | Unique. Lowercase letter first, then letters, digits or _, up to 40. |
fields[].label |
string |
Yes | Must not be blank. |
fields[].type |
string |
No | Defaults to text. |
fields[].show_in_form |
boolean |
No | Defaults to true; the other four switches default to false. |
{
"fields": [
{
"key": "director_cut",
"label": "Director's cut",
"type": "checkbox",
"applies_to": "movie",
"show_frontend": true,
"filter_admin": true
}
]
}
Responses
200 OK. data is the definitions as stored.
{
"success": true,
"data": [
{
"key": "director_cut",
"label": "Director's cut",
"type": "checkbox",
"options": [],
"applies_to": "movie",
"placeholder": "",
"show_in_form": true,
"show_frontend": true,
"filter_admin": true,
"search_admin": false,
"search_frontend": false
}
]
}
| Field | Type | Meaning |
|---|---|---|
data[].key |
string |
Lowercase letter first, then letters, digits or _, up to 40 |
data[].label |
string |
What the editor and viewers see |
data[].type |
string |
text, textarea, number, select, checkbox, date or url |
data[].options |
string[] |
The choices of a select |
data[].applies_to |
string |
all, series or movie |
data[].placeholder |
string |
Hint in the empty input |
data[].show_in_form |
boolean |
Series editor |
data[].show_frontend |
boolean |
Viewer series page |
data[].filter_admin |
boolean |
Admin filters |
data[].search_admin |
boolean |
Admin search |
data[].search_frontend |
boolean |
Viewer search |
Errors
| Status | Code | When |
|---|---|---|
401 / 403 |
plugixa_stream_forbidden |
The caller lacks the capability. |
422 |
plugixa_stream_invalid |
A field has no label or an invalid key, or two fields share a key. |
Plus the errors every endpoint can return.
Examples
curl -s -X PUT "https://your-site.example/wp-json/plugixa-stream/v1/admin/custom-fields" \
-u "$WP_USER:$WP_APP_PASSWORD" \
-H "Content-Type: application/json" \
-d '{"fields":[{"key":"director_cut","label":"Director's cut","type":"checkbox","applies_to":"movie","show_frontend":true,"filter_admin":true}]}'
<?php
$ch = curl_init('https://your-site.example/wp-json/plugixa-stream/v1/admin/custom-fields');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_USERPWD => getenv('WP_USER') . ':' . getenv('WP_APP_PASSWORD'),
CURLOPT_HTTPHEADER => ['Content-Type: application/json'],
CURLOPT_POSTFIELDS => json_encode([
'fields' => [
[
'key' => 'director_cut',
'label' => 'Director\'s cut',
'type' => 'checkbox',
'applies_to' => 'movie',
'show_frontend' => true,
'filter_admin' => true,
],
],
]),
]);
$response = json_decode(curl_exec($ch), true);
curl_close($ch);
const response = await fetch('https://your-site.example/wp-json/plugixa-stream/v1/admin/custom-fields', {
method: 'PUT',
headers: {
'Authorization': `Basic ${btoa(`${process.env.WP_USER}:${process.env.WP_APP_PASSWORD}`)}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({ fields: [{ key: 'director_cut', label: 'Director\'s cut', type: 'checkbox', applies_to: 'movie', show_frontend: true, filter_admin: true }] }),
});
const { data } = await response.json();
Quick Links
Share