Contents
On this page

Update Testimonial - Plugixa Testimonial

PUT /plugixatestimonial/v1/testimonials/{id}

Replace a testimonial’s fields, and optionally its categories and custom field values.

Any signed-in user with the plugixa_testimonial_edit capability or WordPress’s edit_posts (Contributors and up, by default).

Note. This is a replace, not a merge. client_name and testimonial_text are required again, and these fields go back to their defaults when left out: rating to 5, status to pending (which takes an approved testimonial off the site), is_featured to false and display_order to 0. Only client_role, client_company, website_url, video_url, source, client_photo_id, categories and custom_fields are kept when left out. Read the testimonial with Get Testimonial first and send it back with your change.

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

Request

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

Path parameters

Name Type Description
id integer The testimonial’s id

Request body

Content type: application/json

Field Type Required Description
client_name string Yes Who gave the testimonial. Plain text, must not be blank.
testimonial_text string Yes The testimonial. HTML allowed in a WordPress post is kept. At least 10 characters once tags are removed.
rating integer No 1 to 5. Defaults to 5.
client_role string|null No Job title. Plain text.
client_company string|null No Company. Plain text.
client_photo_id integer|null No A Media Library attachment id. null or 0 for none.
website_url string|null No A link shown with the testimonial.
video_url string|null No A YouTube or Vimeo link, or the URL of an .mp4, .webm or .ogg file. See Video testimonials.
status string No pending (the default), approved, rejected or draft.
is_featured boolean No Defaults to false.
display_order integer No Position in the global manual order. Defaults to 0.
source string No Free text. The column defaults to manual.
categories integer[] No Category ids. Ids that do not exist are stored but never shown.
custom_fields object No Values keyed by custom field key. Plain text. An empty string removes a value. Keys are not checked against the custom field definitions.

categories, when sent, replaces the whole set; each category keeps its manual position for this testimonial. custom_fields only touches the keys you send. With WPML or Polylang active, rating, is_featured, status and client_photo_id are copied to every translation of the testimonial. Moving to approved from another status records approved_at and approved_by.

{
  "client_name": "Sarah Johnson",
  "client_role": "Marketing Director",
  "client_company": "Northwind Studio",
  "testimonial_text": "<p>Setup took ten minutes and our reviews finally look professional.</p>",
  "rating": 5,
  "status": "approved",
  "is_featured": true,
  "categories": [
    3
  ],
  "custom_fields": {
    "project_type": "Website redesign"
  }
}

Responses

200 OK.

{
  "success": true,
  "message": "Testimonial updated successfully",
  "data": {
    "id": 42
  }
}
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
400 rest_error “Validation failed”. data.errors names the field: client_name (blank) or testimonial_text (blank or under 10 characters).
400 rest_invalid_param rating outside 1 to 5, or status 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 PUT "https://your-site.example/wp-json/plugixatestimonial/v1/testimonials/42" \
  -u "admin:$WP_APP_PASSWORD" \
  -H "Content-Type: application/json" \
  -d '{"client_name":"Sarah Johnson","client_role":"Marketing Director","client_company":"Northwind Studio","testimonial_text":"<p>Setup took ten minutes and our reviews finally look professional.</p>","rating":5,"status":"approved","is_featured":true,"categories":[3],"custom_fields":{"project_type":"Website redesign"}}'
<?php
$ch = curl_init('https://your-site.example/wp-json/plugixatestimonial/v1/testimonials/42');
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([
        'client_name'      => 'Sarah Johnson',
        'client_role'      => 'Marketing Director',
        'client_company'   => 'Northwind Studio',
        'testimonial_text' => '<p>Setup took ten minutes and our reviews finally look professional.</p>',
        'rating'           => 5,
        'status'           => 'approved',
        'is_featured'      => true,
        'categories'       => [3],
        'custom_fields'    => [
            'project_type' => 'Website redesign',
        ],
    ]),
]);
$response = json_decode(curl_exec($ch), true);
curl_close($ch);
const response = await fetch('https://your-site.example/wp-json/plugixatestimonial/v1/testimonials/42', {
  method: 'PUT',
  headers: {
    'Authorization': 'Basic ' + btoa(`admin:${process.env.WP_APP_PASSWORD}`),
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({ client_name: 'Sarah Johnson', client_role: 'Marketing Director', client_company: 'Northwind Studio', testimonial_text: '<p>Setup took ten minutes and our reviews finally look professional.</p>', rating: 5, status: 'approved', is_featured: true, categories: [3], custom_fields: { project_type: 'Website redesign' } }),
});
const { data } = await response.json();

Quick Links

Share