Contents
On this page

Restore From History - Plugixa Advanced User Role Editor

POST /plugixa-aure/v1/history/{id}/restore

The same restore as Restore Snapshot, with a shorter answer. In the Pro activity log it is recorded with the source restore rather than screen.

Needs the Edit roles permission: plugixa_aure_edit_roles.

Request

POST https://your-site.example/wp-json/plugixa-aure/v1/history/41/restore

Path parameters

Name Type Description
id integer The restore point’s id

Restoring brings back every role as it was: capabilities, names, roles deleted since are created again, and roles created since are deleted (never Administrator). The people the point recorded get their roles and own capabilities back. A new restore point of kind restore is taken first, so a restore can itself be undone.

Responses

200 OK. The point was restored.

{
  "success": true,
  "data": {
    "snapshot": 44,
    "roles": [
      {
        "role": "editor",
        "name": "Editor",
        "granted": [],
        "revoked": [
          "install_plugins"
        ],
        "denied": [],
        "cleared": []
      }
    ],
    "users": [
      {
        "user": 12,
        "name": "Maria Lopez",
        "rolesBefore": [
          "author",
          "editor"
        ],
        "rolesAfter": [
          "author"
        ],
        "granted": [],
        "revoked": [],
        "denied": [],
        "cleared": []
      }
    ]
  }
}
Field Type Meaning
data.snapshot integer The point taken just before, which undoes this restore
data.roles[] array What happened to each role
data.users[] array What happened to each account

Errors

Status Code When
404 plugixa_aure_snapshot_missing No restore point with that id, or its contents cannot be read.
409 plugixa_aure_restore_role_in_use A role that did not exist at that point is held by people the point does not move off it.
403 plugixa_aure_user_not_editable The account holds a role with capabilities you do not hold yourself.
403 plugixa_aure_cannot_grant The change grants, or lifts a block on, a capability you do not hold yourself.
403 plugixa_aure_cannot_revoke The change takes away, or blocks, a capability you do not hold yourself.
409 plugixa_aure_last_administrator The account is the only administrator and would lose the role (single site only).
409 plugixa_aure_self_lockout The change would remove your own access to the editor.

Plus the errors every endpoint can return.

Examples

curl -s -X POST "https://your-site.example/wp-json/plugixa-aure/v1/history/41/restore" \
  -u "admin:$WP_APP_PASSWORD"
<?php
$ch = curl_init('https://your-site.example/wp-json/plugixa-aure/v1/history/41/restore');
curl_setopt_array($ch, [
    CURLOPT_CUSTOMREQUEST  => 'POST',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_USERPWD        => 'admin:' . getenv('WP_APP_PASSWORD'),
]);
$response = json_decode(curl_exec($ch), true);
curl_close($ch);
const response = await fetch('https://your-site.example/wp-json/plugixa-aure/v1/history/41/restore', {
  method: 'POST',
  headers: {
    'Authorization': 'Basic ' + btoa(`admin:${process.env.WP_APP_PASSWORD}`),
  },
});
const { data } = await response.json();

Quick Links

Share