Contents
On this page
Create Custom Field - Plugixa Team
POST /plugixateam/v1/custom-fields
Define a new field for members. Values are then written per member through the meta object of Create Member and Update Member.
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.
Request
POST https://your-site.example/wp-json/plugixateam/v1/custom-fields
Request body
Content type: application/json
| Field | Type | Required | Description |
|---|---|---|---|
field_label |
string |
Yes | Must not be blank. |
field_key |
string |
No | Lowercase letters, digits and underscores only. Made from the label when empty (Desk number becomes desk_number). Must not already be used by another field. It cannot be changed later. |
field_type |
string |
No | text, textarea, url, number, date, select, checkbox, color, file, email or phone. Defaults to 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. |
placeholder |
string |
No | |
is_required |
boolean |
No | Required on the submission form. Defaults to false. |
show_in_frontend |
boolean |
No | Shown on the site. Defaults to true. |
show_in_form |
boolean |
No | Offered on the submission form. Defaults to true. |
menu_order |
integer |
No | Position among the fields. Defaults to 0. |
{
"field_label": "Pronouns",
"field_type": "select",
"field_options": ["she/her", "he/him", "they/them"],
"show_in_form": true
}
Responses
200 OK. The field was created.
Creating answers 200, not 201.
{
"success": true,
"message": "Custom field created successfully",
"data": {
"id": 4
}
}
| Field | Type | Meaning |
|---|---|---|
data.id |
integer |
The new field’s id |
Errors
| Status | Code | When |
|---|---|---|
400 |
rest_error |
Validation failed. data.errors names each field: field_label blank, field_key with other characters or already used, 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 row. |
Plus the errors every endpoint can return.
Examples
curl -s -X POST "https://your-site.example/wp-json/plugixateam/v1/custom-fields" \
-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"],"show_in_form":true}'
<?php
$ch = curl_init('https://your-site.example/wp-json/plugixateam/v1/custom-fields');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'POST',
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'],
'show_in_form' => true,
]),
]);
$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', {
method: 'POST',
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'],
show_in_form: true,
}),
});
const { data } = await response.json();
Quick Links
Share