Contents
On this page

Moderate Review - Plugixa Recipe

PATCH /plugixa-recipe/v1/reviews/{id}/status

Set only the status of a review.

Needs the plugixa_recipe_edit capability, or WordPress’s edit_posts (Contributor and up). It also needs plugixa_recipe_publish or WordPress’s publish_posts (Author and up). The Reviews app must be on.

Request

PATCH https://your-site.example/wp-json/plugixa-recipe/v1/reviews/41/status

Path parameters

Name Type Description
id integer The review’s id

Request body

Content type: application/json

Field Type Required Description
status string Yes pending, approved, rejected or spam, lower case exactly.

The recipe’s average rating and rating count are worked out again, so approving or rejecting a review shows on the recipe at once.

{
  "status": "approved"
}

Responses

200 OK. data echoes the new status.

{
  "success": true,
  "message": "Review status updated.",
  "data": {
    "id": 41,
    "status": "approved"
  }
}
Field Type Meaning
data.id integer The review’s id
data.status string The status now stored

Errors

Status Code When
400 rest_error status is missing or not one of the four values.
404 rest_error No review with that id.

Plus the errors every endpoint can return.

Examples

curl -s -X PATCH "https://your-site.example/wp-json/plugixa-recipe/v1/reviews/41/status" \
  -u "admin:$WP_APP_PASSWORD" \
  -H "Content-Type: application/json" \
  -d '{"status":"approved"}'
<?php
$ch = curl_init('https://your-site.example/wp-json/plugixa-recipe/v1/reviews/41/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 auth = 'Basic ' + btoa(`admin:${process.env.WP_APP_PASSWORD}`);
const response = await fetch('https://your-site.example/wp-json/plugixa-recipe/v1/reviews/41/status', {
  method: 'PATCH',
  headers: {
    'Authorization': auth,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({"status": "approved"}),
});
const { data } = await response.json();

Quick Links

Share