Contents
On this page

Restore Snapshot - Plugixa Advanced User Role Editor

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

Put the site’s roles, and the people the point recorded, back as they were at a restore point.

Needs the Edit roles permission: plugixa_aure_edit_roles.

Request

POST https://your-site.example/wp-json/plugixa-aure/v1/snapshots/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": {
    "restored": 41,
    "snapshot": 44,
    "changed": {
      "added": [],
      "removed": [
        "support_agent"
      ],
      "updated": [
        "editor"
      ]
    },
    "roles": [
      {
        "role": "editor",
        "name": "Editor",
        "granted": [],
        "revoked": [
          "install_plugins"
        ],
        "denied": [],
        "cleared": []
      },
      {
        "role": "support_agent",
        "name": "Support agent",
        "deleted": true,
        "granted": [],
        "revoked": [],
        "denied": [],
        "cleared": []
      }
    ],
    "users": [
      {
        "user": 12,
        "name": "Maria Lopez",
        "rolesBefore": [
          "author",
          "editor"
        ],
        "rolesAfter": [
          "author"
        ],
        "granted": [],
        "revoked": [],
        "denied": [],
        "cleared": []
      }
    ]
  }
}
Field Type Meaning
data.restored integer The point you restored
data.snapshot integer The point taken just before, which undoes this restore
data.changed.added array Roles created again
data.changed.removed array Roles deleted
data.changed.updated array Roles whose capabilities or name changed
data.roles[] array What happened to each role: role, name, the four change lists, and created, deleted or renamedFrom when they apply
data.users[] array What happened to each account: user, name, rolesBefore, rolesAfter and the four change lists for its own capabilities

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/snapshots/41/restore" \
  -u "admin:$WP_APP_PASSWORD"
<?php
$ch = curl_init('https://your-site.example/wp-json/plugixa-aure/v1/snapshots/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/snapshots/41/restore', {
  method: 'POST',
  headers: {
    'Authorization': 'Basic ' + btoa(`admin:${process.env.WP_APP_PASSWORD}`),
  },
});
const { data } = await response.json();

Quick Links

Share