Contents
On this page

Update Monitor - Plugixa Activity Log

PATCH /plugixa-activity-log/v1/monitors/{id}

Switch one monitor or module on or off. PUT and POST work the same way.

Needs settings access (who can call what).

Request

PATCH https://your-site.example/wp-json/plugixa-activity-log/v1/monitors/comments

Path parameters

Name Type Description
id string The module’s id, from List Monitors

Request body

Content type: application/json

Field Type Required Description
enabled boolean Yes true to switch it on. Only true, 1, "1" and "true" count as on; any other value switches it off.
{
  "enabled": false
}

Switching a module off also clears its scheduled tasks. A real change is recorded in the log as event 9002. From the next request on, the routes of a module switched off answer 404.

Note. A core module (core: true) answers 422 whatever you send, even "enabled": true, with the message “That monitor cannot be switched off.”

Responses

200 OK. data is the whole list after the change.

{
  "success": true,
  "data": [
    {
      "id": "comments",
      "category": "monitors",
      "order": 50,
      "label": "Comments",
      "desc": "New comments and every moderation action taken on them.",
      "icon": "comment",
      "core": false,
      "deps": [],
      "flag": false,
      "enabled": false,
      "available": true
    }
  ]
}

The fields are as in List Monitors.

Errors

Status Code When
404 plugixa_activity_log_unknown_monitor No module with that id.
422 plugixa_activity_log_missing_field The body has no enabled.
422 plugixa_activity_log_monitor_required The module is a core one and cannot be switched.

Plus the errors every endpoint can return.

Examples

curl -s -X PATCH "https://your-site.example/wp-json/plugixa-activity-log/v1/monitors/comments" \
  -u "admin:$WP_APP_PASSWORD" \
  -H "Content-Type: application/json" \
  -d '{"enabled":false}'
<?php
$ch = curl_init('https://your-site.example/wp-json/plugixa-activity-log/v1/monitors/comments');
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(['enabled' => false]),
]);
$response = json_decode(curl_exec($ch), true);
curl_close($ch);
const auth = Buffer.from(`admin:${process.env.WP_APP_PASSWORD}`).toString('base64');
const response = await fetch('https://your-site.example/wp-json/plugixa-activity-log/v1/monitors/comments', {
  method: 'PATCH',
  headers: {
    'Authorization': `Basic ${auth}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({ enabled: false }),
});
const { data } = await response.json();

Quick Links

Share