30 days free. No credit card. Full access from the moment you connect your site.

Start free trial

Activate Code Snippet

snippets/activate-snippet switches a snippet on.

For PHP and universal snippets it reads the state back afterwards, because WPCode’s own save path can refuse an activation without saying so.

At a glance

Abilitysnippets/activate-snippet
ToolsetWPCode — toolset/wpcode
GroupWPCode › Snippets
RequiresWPCode, active on the site
Capabilitymanage_options
SafetyWrites data
RepeatableIdempotent — running it twice leaves the same result
Ships inAcrossAI Abilities Manager 0.0.34 and later

This is the moment code starts running

Activating is the moment the code starts running on the live site. For PHP and universal snippets that means arbitrary code executing on every matching request, which is why the confirmation is here rather than on creation.

The quiet refusal

WPCode test-runs PHP and universal code before letting a snippet go live. If the code errors, it leaves the snippet switched off — and still reports the save as successful. The snippet is not running, the caller was told it worked, and the only trace is an error recorded against the snippet.

This ability reads the state back after the write. When the activation was refused it returns activation_refused with the recorded error, rather than reporting a snippet as live when it is not.

Idempotent: activating something already active changes nothing.

The cache flag in the response is the confirmation that matters. Active and cached means running; active and not cached means something is wrong with the cache, and snippets/get-snippet-status will say what.

Input

NameTypeRequiredWhat it is
idintegerYesSnippet ID.
confirmbooleanYes — must be trueThe irreversibility gate. Without it the call is refused before anything is touched.

What comes back

NameTypeWhat it is
snippetobjectThe snippet after the attempt, including whether the activation was refused and why.
in_cachebooleanWhether WPCode’s loader cache holds the snippet. This, not the post status, is what decides whether it actually runs.
safe_modebooleanWhether safe mode is active. When it is, no snippet runs regardless of everything else.
successbooleanWhether the call completed.
messagestringA one-line summary of what happened, suitable for showing a human.
error_codestringPresent 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:

Switch on the snippet I just created.

It resolves to one call:

{
  "ability": "snippets/activate-snippet",
  "parameters": {
    "id": 88,
    "confirm": true
  }
}

Worth knowing

  • activation_refused means the code errored during WPCode’s check. The snippet is still off.
  • Safe mode suppresses everything. A snippet can activate cleanly and still not run.
  • Idempotent.
  • Deactivating needs no confirmation — only switching code on does.

Related abilities


Get the plugins:
AcrossAI Abilities Manager · AcrossAI MCP Manager

Browse the rest: Every ability, by category


Keep reading