Contents
On this page

Change Testimonial Status - Plugixa Testimonial

PATCH /plugixatestimonial/v1/testimonials/{id}/status

Change only a testimonial’s status: the moderation switch.

Any signed-in user with the plugixa_testimonial_approve capability or WordPress’s publish_posts (Authors and up, by default).

Note. There is no existence check: an id that matches nothing still answers 200 with the success message, and nothing changes.

Request

PATCH https://your-site.example/wp-json/plugixatestimonial/v1/testimonials/42/status

Path parameters

Name Type Description
id integer The testimonial’s id

Request body

Content type: application/json

Field Type Required Description
status string Yes pending, approved, rejected or draft.

Setting approved records approved_at and approved_by every time, even when the testimonial was already approved. Other fields are not touched, and translations are not changed.

{
  "status": "approved"
}

Responses

200 OK.

{
  "success": true,
  "message": "Status updated successfully",
  "data": {
    "id": 42,
    "status": "approved"
  }
}
Field Type Meaning
data.id integer The id you sent
data.status string The new status
message string A human-readable confirmation, translated to the site language

Errors

Status Code When
400 rest_error “Invalid status”: status is missing or not one of the four values.
500 rest_error The database refused the update.

Plus the errors every endpoint can return.

Examples

curl -s -X PATCH "https://your-site.example/wp-json/plugixatestimonial/v1/testimonials/42/status" \
  -u "admin:$WP_APP_PASSWORD" \
  -H "Content-Type: application/json" \
  -d '{"status":"approved"}'
<?php
$ch = curl_init('https://your-site.example/wp-json/plugixatestimonial/v1/testimonials/42/status');
curl_setopt_array($ch, [
    CURLOPT_CUSTOMREQUEST  => 'PATCH',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_USERPWD        => 'admin:' . getenv('WP_APP_PASSWORD'),
    CURLOPT_HTTPHEADER     => ['Content-Type: application/json'],
    CURLOPT_POSTFIELDS     => json_encode([
        'status' => 'approved',
    ]),
]);
$response = json_decode(curl_exec($ch), true);
curl_close($ch);
const response = await fetch('https://your-site.example/wp-json/plugixatestimonial/v1/testimonials/42/status', {
  method: 'PATCH',
  headers: {
    'Authorization': 'Basic ' + btoa(`admin:${process.env.WP_APP_PASSWORD}`),
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({ status: 'approved' }),
});
const { data } = await response.json();

Quick Links

Share