Contents
On this page

Delete Role - Plugixa Advanced User Role Editor

DELETE /plugixa-aure/v1/roles/{slug}

Delete a role. When people hold it, name the role they move to.

Needs the Edit roles permission: plugixa_aure_edit_roles.

Note. Moving the role’s holders is not checked against your own access. If you hold the role you delete, you are moved to reassign_to like everyone else, even when that role cannot open the editor.

Request

DELETE https://your-site.example/wp-json/plugixa-aure/v1/roles/support_agent?reassign_to=author

Path parameters

Name Type Description
slug string The role to delete

Query parameters

Name Type Default Description
reassign_to string The role its holders move to. Required when anyone holds the role. You must hold every capability that role grants. Can also be sent in a JSON body.

Each holder is given reassign_to first and then loses the deleted role, so nobody is left without a role. A restore point is taken first and records the people moved (up to 500), so Restore Snapshot brings the role and its holders back.

Responses

200 OK. The role is gone.

{
  "success": true,
  "data": {
    "deleted": "support_agent",
    "usersMoved": 3,
    "reassigned": "author",
    "roles": [
      {
        "slug": "administrator",
        "name": "Administrator",
        "users": 2,
        "granted": 61,
        "denied": 0,
        "version": "9b1e44c0a7d2",
        "protected": true,
        "editable": false,
        "assignable": true
      },
      {
        "slug": "editor",
        "name": "Editor",
        "users": 4,
        "granted": 34,
        "denied": 0,
        "version": "3f9c2a71b0de",
        "protected": false,
        "editable": true,
        "assignable": true
      }
    ],
    "grants": {
      "administrator": {
        "install_plugins": 1,
        "manage_options": 1,
        "read": 1
      },
      "editor": {
        "edit_posts": 1,
        "publish_posts": 1,
        "read": 1
      }
    }
  }
}
Field Type Meaning
data.deleted string The deleted role’s slug
data.usersMoved integer How many people were moved
data.reassigned string|null The role they moved to, or null when none was given
data.roles array The roles that remain
data.grants object Their capability maps

Errors

Status Code When
403 plugixa_aure_role_protected The role is Administrator, which cannot be deleted.
404 plugixa_aure_unknown_role The role, or the reassign_to role, does not exist.
409 plugixa_aure_role_in_use People hold the role and reassign_to is missing.
403 plugixa_aure_cannot_grant / plugixa_aure_cannot_revoke reassign_to grants or blocks a capability you do not hold.

Plus the errors every endpoint can return.

Examples

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

Quick Links

Share