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

Start free trial

Set Snippet Conditional Logic

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

Abilitysnippets/set-conditional-logic
ToolsetWPCode — toolset/wpcode
GroupWPCode › Placement
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

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

NameTypeRequiredWhat it is
idintegerYesSnippet ID.
enabledbooleanYesWhether the rules apply at all. False keeps them but loads the snippet unconditionally.
groupsarrayNoA 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

NameTypeWhat it is
snippetobjectThe snippet after the write.
conditional_logicobjectThe stored rules.
enabledbooleanWhether the rules are being applied.
safe_modebooleanWhether safe mode is suppressing everything.
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:

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 enabled false to test whether the logic is why a snippet is not appearing.
  • Idempotent.

Related abilities


Get the plugins:
AcrossAI Abilities Manager · AcrossAI MCP Manager

Browse the rest: Every ability, by category


Keep reading