WP-CLI commands

View as Markdown

Every wp adminkeep command — switch features on and off, change settings, clean up comments, replace the custom CSS, set up SMTP and read the email log.

Since 1.5.0, everything on the Adminkeep settings screen, plus the Custom CSS and SMTP screens, is also a WP-CLI command. Use it to set up a new site from a script, to apply the same settings to many sites, or to let an AI agent do the work.

The same reference ships inside the plugin, so it always matches the version you run:

wp help adminkeep
wp help adminkeep smtp set    # every subcommand has its own page

Adminkeep must be active. Nothing here loads on a normal page view: the commands exist only while WP-CLI is running.

At a glance

CommandWhat it does
wp adminkeep feature listEvery feature: id, group, label, on/off, state
wp adminkeep feature enable <id>...Switch features on
wp adminkeep feature disable <id>...Switch features off
wp adminkeep feature get <id>A feature’s settings, and what each accepts
wp adminkeep feature set <id> key=value...Change a feature’s settings
wp adminkeep comments countHow many comments purge would delete
wp adminkeep comments purgeDelete them for good
wp adminkeep css getPrint the site’s Custom CSS
wp adminkeep css set [<file>]Replace it from a file or standard input
wp adminkeep smtp getSMTP settings and where each value comes from
wp adminkeep smtp set --host=... ...Change SMTP settings
wp adminkeep smtp test <to>Send a test email
wp adminkeep smtp import <source>Copy SMTP settings from another plugin (wp-mail-smtp)
wp adminkeep email-log listLogged email, newest first
wp adminkeep email-log get <id>One logged email, content included
wp adminkeep email-log countHow many emails are logged
wp adminkeep email-log purgePermanently delete logged email
wp adminkeep email-log import <source>Copy another plugin’s log in
wp adminkeep emails listWordPress core’s own emails, the ones Nice Default Emails covers
wp adminkeep emails send <id>... --to=<email>Send them to one address, to see how they look
wp adminkeep setting get [<key>]Plugin-level settings: key, value, type, accepted values; with a key, just its value
wp adminkeep setting set key=value...Change plugin-level settings, such as hide_unused=true

Features

wp adminkeep feature list
wp adminkeep feature list --enabled --fields=id --format=csv
wp adminkeep feature list --group=site_lock

feature list is where the ids come from. The groups are site_lock, content, appearance, admin and email.

idFeature
disable_commentsDisable Comments
registration_lockRegistration Lockdown (disable user registration)
disable_xmlrpcDisable XML-RPC
disable_file_editDisable File Editing
install_lockInstallation Lockdown (block plugin and theme installs)
duplicateDuplicate
live_draftLive Draft
keep_urlKeep URL
orderOrder
replace_mediaReplace Media
custom_cssCustom CSS
user_columnsUser Registration Date
smtpSMTP
email_logEmail Log
nice_emailsNice Default Emails

Switch a feature on or off

wp adminkeep feature enable disable_comments
wp adminkeep feature enable disable_xmlrpc disable_file_edit
wp adminkeep feature disable install_lock

Only the switch changes. A feature’s settings are kept while it is off, the same as on the settings screen, and the change takes effect from the next request.

Read and change a feature’s settings

wp adminkeep feature get order

feature get prints one row per setting: its key, the current value, its type, and what feature set accepts for it. That table is the reference for a feature’s keys, so there is no list to look up anywhere else.

# Manual ordering for posts and pages, new posts at the top.
wp adminkeep feature set order post_types=post,page new_post_position=top

# Keep replaced media files for two weeks.
wp adminkeep feature set replace_media retain_days=14

Values are true or false for a switch, a whole number, plain text, or a comma-separated list. A list replaces what is stored, and an empty value empties it. Everything you don’t name is kept. feature set does not switch the feature on; that is feature enable.

What each setting means is covered in Configuration.

Comments

wp adminkeep comments count
wp adminkeep comments purge

This is the same cleanup as the button under Disable Comments, with the same guards. Read Comment cleanup first: it is the one thing in the plugin that deletes data, and it cannot be undone.

  • By default only spam and trash are counted and deleted.
  • --approved adds approved and pending comments.
  • --woo adds WooCommerce order notes, webhook logs and product reviews. Leave it out on a store unless you mean it.
  • count prints a bare number, so a script can read it. Give it the same flags you plan to give purge.
  • purge shows the number and asks before deleting. --yes skips the question.

It runs in batches, so a very large site will not time out, and it works whether or not the Disable Comments feature is on.

Custom CSS

wp adminkeep css get > site.css
wp adminkeep css set site.css
cat site.css | wp adminkeep css set

css get prints the stored CSS and nothing else, so it is safe to redirect into a file. css set replaces the stored CSS with a file’s contents, or with standard input when you leave the file out or pass -. The CSS is checked the way the Custom CSS screen checks it: anything that looks like an HTML tag is refused.

Empty input clears the CSS. If CSS is already stored, clearing it asks for confirmation first; --yes skips the question.

The CSS is only printed on your site while the feature is on: wp adminkeep feature enable custom_css.

SMTP

wp adminkeep smtp set --host=smtp.example.com --port=587 --encryption=tls
wp adminkeep smtp set --auth --username=apikey
printf %s "$SMTP_PASSWORD" | wp adminkeep smtp set --password-stdin
wp adminkeep smtp set [email protected] --from-name="Example"
wp adminkeep feature enable smtp
wp adminkeep smtp test [email protected]
wp adminkeep smtp import wp-mail-smtp --dry-run
wp adminkeep smtp import wp-mail-smtp

smtp set changes only what you name; everything else is kept.

FlagMeaning
--host=<host>SMTP server
--port=<port>1 to 65535. Usually 587 (tls) or 465 (ssl)
--encryption=<encryption>none, ssl or tls
--auth / --no-authWhether the server needs a username and password
--username=<username>SMTP username
--password-stdinRead the password from standard input
--password=<password>The password, in plain sight. Prefer --password-stdin
--clear-passwordRemove the saved password
--from-email=<email>Address email is sent from. An empty value clears it
--from-name=<name>Name email is sent from
--force-from / --no-force-fromUse the From address even when a plugin sets its own
--force-name / --no-force-nameUse the From name even when a plugin sets its own

The password. It is never printed, by any command. --password-stdin keeps it out of your shell history and out of the process list; --password= puts it in both.

Settings in wp-config.php. A setting fixed by an ADMINKEEP_SMTP_* constant cannot be changed from the command line, the same as on the screen. smtp get shows where each value comes from, so you can see which ones are fixed.

The test email. smtp test needs the SMTP feature on and a server configured; otherwise it stops with an error instead of reporting a success that went out some other way. When sending fails, it prints the server’s side of the conversation with the username and password removed, and exits with an error. --log prints that conversation even when the email is sent.

Copying from WP Mail SMTP. Since 1.10.0, smtp import wp-mail-smtp copies WP Mail SMTP’s SMTP connection: server, port, encryption, authentication, username, password, From address and name, and whether each is forced. It replaces your current Adminkeep SMTP settings, except values held by ADMINKEEP_SMTP_* constants in wp-config.php, which are kept. WP Mail SMTP’s settings are only read, and it does not need to be active.

FlagMeaning
<source>Where to copy from. Today there is one: wp-mail-smtp
--dry-runShow what would be copied without changing anything

The output names the fields copied and the ones kept from wp-config.php, not their values, and says what became of the password: copied and stored encrypted, kept from wp-config.php, left as it was because WP Mail SMTP has none saved, or left as it was because WP Mail SMTP’s saved password could not be read. In that last case set it with smtp set --password-stdin. Only an SMTP connection can be copied: if WP Mail SMTP is set to an API mailer such as SendLayer or the Gmail API, or has no SMTP host, the command exits 1 and names the reason. After copying, send a test email with smtp test, then deactivate WP Mail SMTP if it is still active, so the two plugins do not both configure the mailer.

Choosing a provider, ports and the constants are covered in the WordPress SMTP settings guide.

Email Log

wp adminkeep email-log list --status=failed --format=json
wp adminkeep email-log get 482
wp adminkeep email-log count --status=failed
wp adminkeep email-log purge --older-than=90 --yes
wp adminkeep email-log import email-log --dry-run

This is the same log as Tools → Email Log, and it works whether or not the Email Log feature is on: what was logged stays readable after logging is switched off. Read Email Log first for what each status means and what is kept.

  • list takes --status=<sent|failed|unconfirmed>, --search=<text> (matches the recipient, sender or subject, never the body), --since=<date> (read as UTC, e.g. 2026-09-01), --limit=<number> (default 50, at most 500), and --format=<table|json|csv|yaml|ids|count>. It never prints a body — use get for one email’s content.
  • get <id> prints one email in full, including its content.
  • count takes --status only, and prints a bare number.
  • purge takes --all or --older-than=<days>, never both. It asks for confirmation first, unless you pass --yes. This cannot be undone.
  • import <source> copies another plugin’s log in. email-log is currently the only source, for the Email Log plugin — see moving from the Email Log plugin. It needs Email Log switched on first, and reads the other plugin’s table without changing it. --dry-run reports the counts without writing anything.

Core emails

wp adminkeep feature enable nice_emails
wp adminkeep emails list
wp adminkeep emails list --format=ids
wp adminkeep emails send password_reset [email protected]
wp adminkeep emails send new_user comment_notification [email protected]
wp adminkeep emails send --all [email protected]

These are the emails WordPress core writes itself, the ones Nice Default Emails dresses up. Most of them are hard to trigger on purpose (a new account, a comment held for moderation, an automatic update, a personal data request), so send makes WordPress send them for you.

  • list prints each email this site can send: its id, what it is, and the core function that sends it. The six multisite emails are listed only on a multisite network. Takes --format=<table|json|csv|yaml|ids|count>.
  • send takes one or more ids from list, or --all, but not both, and needs --to=<email>. It prints one row per email (id, subject, whether it was wrapped, status) and takes --format=<table|json|csv|yaml>.

Each email is sent by the core function that sends it for real, so it arrives exactly as your site would send it: through your mailer (the SMTP feature, when on), in the Nice Default Emails layout, and recorded by Email Log when that is on. Only the recipient is changed: every email goes to --to, and to nobody else.

What the emails need is made for the run and deleted after it: a throwaway subscriber for the account emails (no real account’s password or reset link changes), a private post with two comments, personal data requests. Settings core writes while sending, such as a pending admin email change or a recovery mode key, are put back, so the links in those emails do nothing. If something could not be cleaned up, the command says what, so you can remove it by hand.

send needs Nice Default Emails switched on; otherwise it stops rather than sending plain text. It exits 1 if any email fails, and names the one that did.

Plugin-level settings

wp adminkeep setting get
wp adminkeep setting get hide_unused
wp adminkeep setting set hide_unused=true
wp adminkeep setting set hide_unused=false

Since 1.8.1. Settings that belong to the plugin itself rather than to one feature, in the same key=value shape as feature set. Today there is one: hide_unused, the same as the Hide unused features switch on the settings screen, which hides switched-off features from its nav. It is a site setting, so no --user is needed (WP-CLI’s global --user is accepted and ignored). get <key> prints the value and nothing else; get alone lists every setting and takes --format=json. A wrong key or value exits 1 and writes nothing.

This replaces 1.8.0’s wp adminkeep view get|hide-unused|show-all --user=<user>, which set the view for one administrator at a time.

For scripts and AI agents

  • feature list, feature get, smtp get, email-log list, emails list and emails send take --format=json (also csv, yaml and table; email-log list and emails list also take ids and count).
  • Exit code 0 means the change was made. Any mistake (an unknown id, an unknown key, the wrong type of value) exits 1, names the valid choices, and writes nothing.
  • comments purge and email-log purge always ask first, and css set asks before clearing stored CSS. Pass --yes to skip the question.
  • A change takes effect from the next request.
  • On multisite, pick the site with WP-CLI’s own --url=<site>.
  • wp help adminkeep is written as a complete reference. An agent that reads it needs nothing else.

A new site, set up in one go:

wp plugin install adminkeep --activate
wp adminkeep feature enable disable_comments disable_xmlrpc disable_file_edit
wp adminkeep feature enable order
wp adminkeep feature set order post_types=post,page
wp adminkeep feature list --enabled --format=json

Switch on what you need. Forget the rest.

A free WordPress plugin — GPL, instantly reversible, and updates come to you.

Type to search the whole site.