Contents
On this page
Update Custom Field - Plugixa Testimonial
PUT /plugixatestimonial/v1/custom-fields/{id}
Replace a custom field definition. Its key never changes.
Administrators only: the user needs WordPress’s manage_options capability. No plugin capability opens this route.
Note. This is a full replace. A field you leave out is reset:
field_typetotext,placeholderto empty,is_requiredtofalse,show_in_frontendtotrue,menu_orderto0,statustopublishandfield_optionsto none (so aselectfield sent without its options is refused).field_keyis ignored: the stored key is always kept.
Request
PUT https://your-site.example/wp-json/plugixatestimonial/v1/custom-fields/5
Path parameters
| Name | Type | Description |
|---|---|---|
id |
integer |
The field’s id |
Request body
Content type: application/json
| Field | Type | Required | Description |
|---|---|---|---|
field_label |
string |
Yes | Plain text, must not be blank. |
field_type |
string |
No | text (the default), textarea, url, number, date, select, checkbox or color. |
field_options |
string[] |
See below | The choices. Required, with at least one, for a select field. A JSON-encoded array string is accepted too. |
placeholder |
string |
No | Placeholder text on the form. |
is_required |
boolean |
No | Defaults to false. |
show_in_frontend |
boolean |
No | Defaults to true. |
menu_order |
integer |
No | Defaults to 0. |
status |
string |
No | publish (the default), draft or trash. Any other value is saved as publish. |
With WPML or Polylang active, status is copied to every translation.
{
"field_label": "Project type",
"field_type": "select",
"field_options": [
"Website redesign",
"Branding",
"SEO"
],
"show_in_frontend": true
}
Responses
200 OK.
{
"success": true,
"message": "Custom field updated successfully",
"data": {
"id": 5
}
}
| Field | Type | Meaning |
|---|---|---|
data.id |
integer |
The id you sent |
message |
string |
A human-readable confirmation, translated to the site language |
Errors
| Status | Code | When |
|---|---|---|
404 |
rest_error |
No field with that id. |
400 |
rest_error |
“Validation failed”. data.errors names the field: field_label, field_type or field_options. |
500 |
rest_error |
The database refused the update. |
Plus the errors every endpoint can return.
Examples
curl -s -X PUT "https://your-site.example/wp-json/plugixatestimonial/v1/custom-fields/5" \
-u "admin:$WP_APP_PASSWORD" \
-H "Content-Type: application/json" \
-d '{"field_label":"Project type","field_type":"select","field_options":["Website redesign","Branding","SEO"],"show_in_frontend":true}'
<?php
$ch = curl_init('https://your-site.example/wp-json/plugixatestimonial/v1/custom-fields/5');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_USERPWD => 'admin:' . getenv('WP_APP_PASSWORD'),
CURLOPT_HTTPHEADER => ['Content-Type: application/json'],
CURLOPT_POSTFIELDS => json_encode([
'field_label' => 'Project type',
'field_type' => 'select',
'field_options' => ['Website redesign', 'Branding', 'SEO'],
'show_in_frontend' => true,
]),
]);
$response = json_decode(curl_exec($ch), true);
curl_close($ch);
const response = await fetch('https://your-site.example/wp-json/plugixatestimonial/v1/custom-fields/5', {
method: 'PUT',
headers: {
'Authorization': 'Basic ' + btoa(`admin:${process.env.WP_APP_PASSWORD}`),
'Content-Type': 'application/json',
},
body: JSON.stringify({ field_label: 'Project type', field_type: 'select', field_options: ['Website redesign', 'Branding', 'SEO'], show_in_frontend: true }),
});
const { data } = await response.json();
Quick Links
Share