Contents
On this page

Reorder Custom Fields - Plugixa Team

POST /plugixateam/v1/custom-fields/reorder

Set the position of several custom fields at once. The order is the one used on profiles and on the submission form.

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/reorder

Request body

Content type: application/json

Field Type Required Description
items array Yes { "id": 4, "menu_order": 0 } objects. display_order is accepted in place of menu_order. An item without an id or a position is skipped, and so is an unknown id.
{
  "items": [
    { "id": 4, "menu_order": 0 },
    { "id": 2, "menu_order": 1 },
    { "id": 7, "menu_order": 2 }
  ]
}

Responses

200 OK. The order was saved.

{
  "success": true,
  "message": "Order updated successfully",
  "data": null
}
Field Type Meaning
data null Nothing is returned

Errors

Status Code When
400 rest_error items is missing, empty or not an array.
404 rest_no_route The site runs the free build.

Plus the errors every endpoint can return.

Examples

curl -s -X POST "https://your-site.example/wp-json/plugixateam/v1/custom-fields/reorder" \
  -u "admin:$WP_APP_PASSWORD" \
  -H "Content-Type: application/json" \
  -d '{"items":[{"id":4,"menu_order":0},{"id":2,"menu_order":1},{"id":7,"menu_order":2}]}'
<?php
$ch = curl_init('https://your-site.example/wp-json/plugixateam/v1/custom-fields/reorder');
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([
        'items' => [
            [
                'id'         => 4,
                'menu_order' => 0,
            ],
            [
                'id'         => 2,
                'menu_order' => 1,
            ],
            [
                'id'         => 7,
                'menu_order' => 2,
            ],
        ],
    ]),
]);
$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/reorder', {
  method: 'POST',
  headers: {
    'Authorization': `Basic ${auth}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    items: [
      { id: 4, menu_order: 0 },
      { id: 2, menu_order: 1 },
      { id: 7, menu_order: 2 },
    ],
  }),
});
const { data } = await response.json();

Quick Links

Share