snippets/update-snippet changes a snippet: its code, title, note, priority, tags or custom shortcode. Only the fields you send are touched.
If the snippet is active, the save re-runs WPCode’s activation check — and the result of that check is reported rather than assumed.
At a glance
| Ability | snippets/update-snippet |
| Toolset | WPCode — toolset/wpcode |
| Group | WPCode › Snippets |
| Requires | WPCode, active on the site |
| Capability | manage_options |
| Safety | Writes data |
| Repeatable | Not idempotent — each call changes the row set, so re-running is not a no-op |
| Ships in | AcrossAI Abilities Manager 0.0.34 and later |
Why editing executable code needs confirmation
PHP and universal snippets execute on this site. Code arriving through an assistant is code somebody described rather than wrote, and the gap between the description and what the code does is exactly where this goes wrong. The confirmation is there to make that a deliberate step rather than a consequence of a sentence. Editing an active PHP snippet is the sharper case: the new code runs on the next request, and if it fatals WPCode switches the snippet off.
The check that runs on save
WPCode test-runs PHP and universal code when a snippet is saved in an active state. If the code errors, it leaves the snippet switched off and still reports the save as successful. From the outside that is indistinguishable from a working edit until somebody notices the feature is gone.
So this reads the state back after saving. A snippet that went in and came out inactive is reported as such, with the error WPCode recorded, instead of a clean success.
That makes editing an active PHP snippet a two-outcome operation, and both outcomes are visible: either the code took and the snippet is still running, or it did not and the snippet is off with a reason attached.
Partial updates are the default. Sending only priority leaves the code alone.
Input
| Name | Type | Required | What it is |
|---|---|---|---|
id | integer | Yes | Snippet ID. |
code_type | string | No | Change the code type. Omit to keep the current one. |
title | string | No | Snippet title. |
code | string | No | The snippet body. |
note | string | No | Internal note. Never output anywhere on the site. |
priority | integer | No — defaults to 10 | Execution order; lower runs earlier. |
custom_shortcode | string | No | A custom shortcode tag for rendering this snippet manually. |
tags | array | No | Tags, as a list of strings. |
confirm | boolean | Yes — must be true | The irreversibility gate. Without it the call is refused before anything is touched. |
What comes back
| Name | Type | What it is |
|---|---|---|
snippet | object | The snippet after the write, including its active state and any error recorded by the save-time check. |
in_cache | boolean | Whether WPCode’s loader cache holds the snippet. This, not the post status, is what decides whether it actually runs. |
safe_mode | boolean | Whether safe mode is active. When it is, no snippet runs regardless of everything else. |
success | boolean | Whether the call completed. |
message | string | A one-line summary of what happened, suitable for showing a human. |
error_code | string | Present only on failure — a stable machine-readable reason, such as a missing field, a wrong field type or an unmet confirmation. |
Example
Ask your assistant:
Change the priority on snippet 88 so it runs earlier.
It resolves to one call:
{
"ability": "snippets/update-snippet",
"parameters": {
"id": 88,
"priority": 5
}
}Worth knowing
- Editing an active PHP snippet can switch it off. The response says so when it happens.
- Read the active state in the response — do not assume the edit left it running.
- Clear the recorded error with
snippets/clear-snippet-errorsafter fixing the code, so a later failure is unambiguous. - Confirmation applies to
phpanduniversal.
Related abilities
- Get Code Snippet — read the current code first
- Clear Snippet Errors — after a successful fix
- Activate Code Snippet — switch it back on
Get the plugins:
AcrossAI Abilities Manager · AcrossAI MCP Manager
Browse the rest: Every ability, by category