Contents
On this page
Update Role - Plugixa Advanced User Role Editor
PATCH /plugixa-aure/v1/roles/{slug}
Rename a role, replace its capabilities, or both in one request.
Needs the Edit roles permission: plugixa_aure_edit_roles.
Note.
capabilitiesis the role’s whole map, not a list of changes. A capability the role holds now and that is missing from what you send is taken away. Read the role first with List Roles and send the full map back.
Request
PATCH https://your-site.example/wp-json/plugixa-aure/v1/roles/support_agent
Path parameters
| Name | Type | Description |
|---|---|---|
slug |
string |
The role’s slug: lower-case letters, digits, _ and - |
Request body
Content type: application/json
| Field | Type | Required | Description |
|---|---|---|---|
name |
string |
No | New display name. An empty string is ignored. |
capabilities |
object |
No | The complete new map: capability to true (grant) or false (block). Leave it out to keep the capabilities as they are. |
The rename is saved first. If the capability change is then refused, the new name stays. Send real JSON booleans inside capabilities; null is dropped. Every change goes through the safety guardrails, and a restore point is taken before it is saved.
{
"name": "Support team",
"capabilities": {
"read": true,
"edit_posts": true,
"moderate_comments": true,
"upload_files": true
}
}
Responses
200 OK. The role was saved.
The keys depend on what you sent: roles comes with a rename or a capability change, change and grants only with a capability change. With neither, data is just {"role": "..."}.
{
"success": true,
"data": {
"role": "support_agent",
"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
},
{
"slug": "support_agent",
"name": "Support agent",
"users": 0,
"granted": 3,
"denied": 1,
"version": "5d0a8e13c4f7",
"protected": false,
"editable": true,
"assignable": true
}
],
"change": {
"granted": [],
"revoked": [],
"denied": [],
"cleared": [
"upload_files"
]
},
"grants": {
"administrator": {
"install_plugins": 1,
"manage_options": 1,
"read": 1
},
"editor": {
"edit_posts": 1,
"publish_posts": 1,
"read": 1
},
"support_agent": {
"edit_posts": 1,
"moderate_comments": 1,
"read": 1,
"upload_files": 0
}
}
}
}
| Field | Type | Meaning |
|---|---|---|
data.role |
string |
The role’s slug |
data.change.granted |
array |
Capabilities newly granted |
data.change.revoked |
array |
Capabilities that were granted and are now absent |
data.change.denied |
array |
Capabilities newly blocked |
data.change.cleared |
array |
Capabilities that were blocked and are now absent |
data.roles |
array |
Every role, as in List Roles |
data.grants |
object |
Every role’s capability map |
Errors
| Status | Code | When |
|---|---|---|
404 |
plugixa_aure_unknown_role |
The role does not exist. |
422 |
plugixa_aure_bad_name |
name is only whitespace or markup. |
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_self_lockout |
The change would remove your own access to the editor. |
Plus the errors every endpoint can return.
Examples
curl -s -X PATCH "https://your-site.example/wp-json/plugixa-aure/v1/roles/support_agent" \
-u "admin:$WP_APP_PASSWORD" \
-H "Content-Type: application/json" \
-d '{"name":"Support team","capabilities":{"read":true,"edit_posts":true,"moderate_comments":true,"upload_files":true}}'
<?php
$ch = curl_init('https://your-site.example/wp-json/plugixa-aure/v1/roles/support_agent');
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([
'name' => 'Support team',
'capabilities' => [
'read' => true,
'edit_posts' => true,
'moderate_comments' => true,
'upload_files' => true,
],
]),
]);
$response = json_decode(curl_exec($ch), true);
curl_close($ch);
const response = await fetch('https://your-site.example/wp-json/plugixa-aure/v1/roles/support_agent', {
method: 'PATCH',
headers: {
'Authorization': 'Basic ' + btoa(`admin:${process.env.WP_APP_PASSWORD}`),
'Content-Type': 'application/json',
},
body: JSON.stringify({ name: 'Support team', capabilities: { read: true, edit_posts: true, moderate_comments: true, upload_files: true } }),
});
const { data } = await response.json();
Quick Links
Share