snippets/set-conditional-logic sets the conditional-logic rules that decide when a snippet loads, or switches the rules off while keeping them.
On the free edition, rule types it cannot evaluate are refused by name rather than stored.
At a glance
| Ability | snippets/set-conditional-logic |
| Toolset | WPCode — toolset/wpcode |
| Group | WPCode › Placement |
| Requires | WPCode, active on the site |
| Capability | manage_options |
| Safety | Writes data |
| Repeatable | Idempotent — running it twice leaves the same result |
| Ships in | AcrossAI Abilities Manager 0.0.34 and later |
The refusal that saves you a week
WPCode Lite evaluates page and user rules. Pro adds device, schedule, WooCommerce and others. The difficulty is that Lite does not reject a Pro rule — it stores it, and then never matches it, so the snippet silently stops appearing with no error anywhere and a rule sitting right there in the admin that looks correct.
So a Pro rule type on a Lite site is refused by name here. You get told which rule is not supported, instead of a snippet that mysteriously vanished.
The rule structure is WPCode’s own: a list of groups, each a list of rules with type, option and value. Groups are OR-ed together; rules within a group are AND-ed. One group of two rules means both must hold; two groups of one means either.
The enabled flag is separate from the rules themselves. Set it false to keep the rules recorded but load the snippet unconditionally — which is how you test whether the logic is the reason something is not appearing, without losing the rules.
Input
| Name | Type | Required | What it is |
|---|---|---|---|
id | integer | Yes | Snippet ID. |
enabled | boolean | Yes | Whether the rules apply at all. False keeps them but loads the snippet unconditionally. |
groups | array | No | A list of rule groups, each a list of rules with type, option and value. Groups are OR-ed; rules inside a group are AND-ed. Supported on the free edition: page and user. |
What comes back
| Name | Type | What it is |
|---|---|---|
snippet | object | The snippet after the write. |
conditional_logic | object | The stored rules. |
enabled | boolean | Whether the rules are being applied. |
safe_mode | boolean | Whether safe mode is suppressing everything. |
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:
Only load snippet 88 for logged-in users.
It resolves to one call:
{
"ability": "snippets/set-conditional-logic",
"parameters": {
"id": 88,
"enabled": true,
"groups": [
[
{ "type": "user", "option": "logged_in", "value": "1" }
]
]
}
}Worth knowing
- Groups are OR-ed, rules within a group are AND-ed. That nesting is the whole grammar.
- Pro rule types are refused by name on the free edition, rather than stored and ignored.
- Set
enabledfalse to test whether the logic is why a snippet is not appearing. - Idempotent.
Related abilities
- Get Code Snippet — read the current rules
- Set Snippet Location — the other placement control
Get the plugins:
AcrossAI Abilities Manager · AcrossAI MCP Manager
Browse the rest: Every ability, by category