Contents
On this page

Update Custom Field - Plugixa Team

PUT /plugixateam/v1/custom-fields/{id}

Replace a custom field’s label, type, options and visibility. Its key never changes.

Needs Plugixa Team Pro. Needs the plugixa_team_settings capability, which only administrators get on activation, or manage_options. Editors fill these fields in on members but cannot change the definitions.

Note. This is a full replace, not a merge. A field you leave out goes back to its create default: field_type becomes text, field_options and placeholder are emptied, is_required becomes false, show_in_frontend and show_in_form become true, and menu_order becomes 0. Read the field first with Get Custom Field and send every field back. Member values already stored are not converted when the type changes.

Request

PUT https://your-site.example/wp-json/plugixateam/v1/custom-fields/4

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 Must not be blank.
field_type string No text, textarea, url, number, date, select, checkbox, color, file, email or phone. Omitted means text.
field_options array For select The choices, as strings. Required, with at least one, for a select field. A JSON-encoded array in a string is accepted too. Omitted means none.
placeholder string No Omitted means empty.
is_required boolean No Required on the submission form. Omitted means false.
show_in_frontend boolean No Shown on the site. Omitted means true.
show_in_form boolean No Offered on the submission form. Omitted means true.
menu_order integer No Position among the fields. Omitted means 0.

A field_key in the body is ignored.

{
  "field_label": "Pronouns",
  "field_type": "select",
  "field_options": ["she/her", "he/him", "they/them", "ze/zir"],
  "placeholder": "",
  "is_required": false,
  "show_in_frontend": true,
  "show_in_form": true,
  "menu_order": 0
}

Responses

200 OK. The field was updated.

{
  "success": true,
  "message": "Custom field updated successfully",
  "data": {
    "id": 4
  }
}
Field Type Meaning
data.id integer The id from the URL

Errors

Status Code When
404 rest_error No field with that id.
400 rest_error Validation failed. data.errors names each field: field_label blank, field_type not in the list, or a select field without options.
404 rest_no_route The site runs the free build.
500 rest_error The database refused the change.

Plus the errors every endpoint can return.

Examples

curl -s -X PUT "https://your-site.example/wp-json/plugixateam/v1/custom-fields/4" \
  -u "admin:$WP_APP_PASSWORD" \
  -H "Content-Type: application/json" \
  -d '{"field_label":"Pronouns","field_type":"select","field_options":["she/her","he/him","they/them","ze/zir"],"placeholder":"","is_required":false,"show_in_frontend":true,"show_in_form":true,"menu_order":0}'
<?php
$ch = curl_init('https://your-site.example/wp-json/plugixateam/v1/custom-fields/4');
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'      => 'Pronouns',
        'field_type'       => 'select',
        'field_options'    => ['she/her', 'he/him', 'they/them', 'ze/zir'],
        'placeholder'      => '',
        'is_required'      => false,
        'show_in_frontend' => true,
        'show_in_form'     => true,
        'menu_order'       => 0,
    ]),
]);
$response = json_decode(curl_exec($ch), true);
curl_close($ch);
const auth = btoa(`admin:${process.env.WP_APP_PASSWORD}`);
const response = await fetch('https://your-site.example/wp-json/plugixateam/v1/custom-fields/4', {
  method: 'PUT',
  headers: {
    'Authorization': `Basic ${auth}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    field_label: 'Pronouns',
    field_type: 'select',
    field_options: ['she/her', 'he/him', 'they/them', 'ze/zir'],
    placeholder: '',
    is_required: false,
    show_in_frontend: true,
    show_in_form: true,
    menu_order: 0,
  }),
});
const { data } = await response.json();

Quick Links

Share