WPCode Logo

WPCode Documentation

Documentation, Reference Materials, and Tutorials for WPCode

Most Popular

Get free tips and resources right in your inbox, along with 500+ others

Follow Us

Letting AI Tools Manage Your Snippets

Would you like an AI assistant or automation tool to add and update code snippets on your site for you?

In this guide, we’ll show you how to turn on AI & Automation Access in WPCode and explain what connected tools can and can’t change.

Requirements: AI & Automation Access needs WordPress 6.9 or later.

Before you get started, make sure WPCode is installed and activated on your WordPress site.

How Do AI Tools Connect to WPCode?

WordPress 6.9 added the Abilities API. It gives AI assistants and automation tools a standard list of actions they can run on your site, called abilities. WPCode adds its own abilities to that list.

A tool connects to your site as one of your WordPress users, for example with an application password. It can only do what that user is allowed to do.

Some WPCode abilities only read information, such as listing your snippets or checking them for errors. Those are always available. The abilities that create or change code stay off until you turn on AI & Automation Access.

Turning On AI and Automation Access

To get started, we’ll switch on the setting that lets connected tools create and change code. If you only want AI tools to read your snippets and error logs, you can leave this setting off.

From your WordPress admin sidebar, go to Code Snippets » Settings. The General Settings tab opens first.

The WPCode General Settings tab opened from the Code Snippets menu in the WordPress admin sidebar, with Settings highlighted in the menu

Next, scroll down to the AI & Automation Access setting, just below Admin Bar Info, and turn its toggle on.

The AI and Automation Access setting below Admin Bar Info, switched on, with an arrow pointing at its toggle

Below the last setting on the tab, click Save Changes.

The AI and Automation Access toggle switched on above the Save Changes button, with an arrow pointing at Save Changes

Once you save, connected tools can use the abilities that create or change code.

Note: If you use WPCode in Headers & Footers mode, this toggle is on the Settings » Header & Footer page instead, below the Footer box. In that mode, the abilities that create or change code only cover your header, body, and footer code.

What Connected Tools Can Do

These read-only abilities are always available to a connected tool:

  • List Code Snippets returns your snippets and whether each one is active.
  • Detect Snippet Errors checks whether WPCode has flagged an error in an active snippet.
  • Get Error Logs returns details of recent snippet errors.
  • Search WPCode Library finds ready-made snippets in the WPCode Library.
  • Get WPCode Settings reads WPCode’s main settings.

Once AI & Automation Access is on, connected tools can also use these abilities:

  • Get Code Snippet returns one snippet with its code and settings.
  • Create Code Snippet adds a new snippet.
  • Update Code Snippet changes the fields it’s given and leaves the rest as they are.
  • Set Code Snippet Status activates or deactivates a snippet.
  • Install Library Snippet adds a snippet from the WPCode Library.
  • Get Headers & Footers returns your site-wide header, body, and footer code.
  • Update Headers & Footers adds to or replaces that site-wide code.

These abilities follow the same rules as the WPCode admin:

  • New snippets are inactive unless the tool asks for them to be active. Snippets installed from the library are always inactive.
  • Before a PHP snippet goes live, WPCode test-runs it. If the code causes an error, the change is refused. Your current code stays live.
  • Code that WPCode doesn’t allow in the admin is refused here too. For example, if PHP snippets are disabled on your site, a tool can’t add PHP snippets either.
  • If the connected user can’t activate snippets, the tool can only edit inactive ones.
  • While Testing Mode is on, every change is refused until you publish or discard your test changes.

To limit what a tool can do, connect it as a user with fewer WPCode permissions. Our Access Control guide shows how to choose which users can edit each type of snippet.

Checking Changes Made by AI Tools

Snippets that AI tools create appear in your Code Snippets list alongside your own. The Author column shows the user the tool connected as.

The Code Snippets list showing a Holiday Hours Banner HTML snippet in the Site Wide Footer location, with its status toggle switched off

In this example, the snippet arrived inactive. It doesn’t run on your site until you switch it on. That gives you a chance to review its code first.

In the paid versions of WPCode, every change a tool saves is also kept in the snippet’s code revisions. You can compare it with earlier versions and restore one if you need to.

That’s it! You now know how to let AI assistants and automation tools manage your snippets, and what they can change. Next, take a look at our guide on using Testing Mode to try snippet changes privately before your visitors see them.

Frequently Asked Questions

Below, we’ve answered some of the most common questions about AI & Automation Access in WPCode.

Can AI tools delete my snippets?

No. Deleting and trashing snippets stays with you in the WPCode admin. A connected tool can deactivate a snippet. You can switch it back on from your Code Snippets list.

What happens when I turn the setting off?

The abilities that create or change code are removed straight away. Connected tools can no longer use them. The read-only abilities stay available. Snippets a tool already created stay on your site.

Do AI tools get the same access as my admin account?

Only if they connect as your admin account. A tool has exactly the WPCode permissions of the user it connects as. If that user can’t edit PHP snippets, the tool can’t either.

Still stuck? How can we help?

Last Updated on

Get Started Today & Add Your Own Snippets

Future-proof your website with WPCode Snippets and improve the way you manage code across all your websites.