Skip to content

WP-CLI commands

Two command groups, both registered only under WP-CLI — they never run on a web request.

Shell access is the authorisation boundary

WP-CLI commands are not gated by the plugin's cpm_access / cpm_manage_all capabilities. Anyone who can run wp on the server can run these. The capability checks still apply to everything done through the browser.

wp cpm squad

Squad management from the command line — useful for setting a club up from a script, or fixing a secretary address without clicking through the admin.

wp cpm squad create

wp cpm squad create <name> [--type=<type>] [--dob-start=<date>] [--dob-end=<date>]
                          [--secretary-email=<email>] [--porcelain]
Option Default What it does
<name> required The squad name
--type=<type> Mixed Mixed or Girls
--dob-start=<date> no lower bound Earliest eligible date of birth, YYYY-MM-DD
--dob-end=<date> no upper bound Latest eligible date of birth, YYYY-MM-DD
--secretary-email=<email> none Team secretary to assign
--porcelain off Print only the new squad ID, for scripting
# A mixed squad.
$ wp cpm squad create "Under 9s"
Success: Created squad "Under 9s" (ID 12).

# A girls squad with a date-of-birth range and a team secretary.
$ wp cpm squad create "U11 Girls" --type=Girls --dob-start=2015-09-01 \
    --dob-end=2016-08-31 --secretary-email=jo@example.com
Success: Created squad "U11 Girls" (ID 13).

The date-of-birth range is what matches waiting-list sign-ups to a squad and what the FA report import uses to place a child, so it is worth setting even when the club thinks in year groups.

wp cpm squad set-secretary

wp cpm squad set-secretary <id> [<email>] [--clear]

Sets or clears a squad's team secretary. The address is stored lower-cased, matching how the access layer derives it from the signed-in user: the WordPress account whose email matches gains access to that squad and nothing else.

$ wp cpm squad set-secretary 12 jo@example.com
Success: Set the team secretary for squad "Under 9s" (ID 12) to jo@example.com.

$ wp cpm squad set-secretary 12 --clear
Success: Cleared the team secretary for squad "Under 9s" (ID 12).

Handing a squad over is this command, or the same field on the squad's detail page.

wp cpm squad list

wp cpm squad list [--format=<format>]

Every squad and its team secretary. --format takes table (default), csv, json, yaml, ids or count.

$ wp cpm squad list
$ wp cpm squad list --format=csv > squads.csv

Use it to find the ID set-secretary wants.

wp cpm generate

Realistic demo data for a development or staging install: seasons, squads, players and guardians, team and season registrations, payment products with GoCardless and offline payment state, and public waiting-list sign-ups.

Names are drawn from a broad range of world cultures, and every email address uses the reserved @example.com domain, so nothing it creates can reach a real inbox.

wp cpm generate all

wp cpm generate all [--players=<number>] [--waiting-list=<number>] [--seed=<number>] [--yes]
Option Default What it does
--players=<number> 40 How many players to create
--waiting-list=<number> 12 How many public sign-ups to create
--seed=<number> random Fixed seed, for a reproducible dataset
--yes off Skip the confirmation prompt
$ wp cpm generate all
Success: Created 40 players, 78 guardians and related data for season 2025/26.

$ wp cpm generate all --players=120 --waiting-list=30 --seed=42 --yes

A fixed --seed makes the same dataset every time, which is what you want for a screenshot, a demo you will run twice, or a bug you need someone else to reproduce.

wp cpm generate reset

wp cpm generate reset [--yes]

Removes everything the generator created and nothing else. Generated records are tagged — players carry a TESTDATA- FA Number prefix, and the IDs of the seasons, squads and products it made are recorded in an option — so real records are left untouched even on a site carrying both.

$ wp cpm generate reset
Success: Removed 40 players, 12 waiting-list entries and 13 demo squads/seasons/products.

The environment gate

Both generator commands refuse to run in a production environment, so they cannot touch a live club's site.

The decision comes from WordPress's standard WP_ENVIRONMENT_TYPE, set as an environment variable or a wp-config.php constant. It defaults to production when unset — so the generator is disabled by default until the environment is explicitly declared as local, development or staging.

# In the shell…
export WP_ENVIRONMENT_TYPE=development
wp cpm generate all

# …or in wp-config.php:
# define( 'WP_ENVIRONMENT_TYPE', 'development' );

There is an escape hatch for a box whose environment type is mislabelled and cannot easily be changed:

CPM_ALLOW_TEST_DATA=1 wp cpm generate all

It works as an environment variable or a PHP constant. Setting it on a production site defeats the only guard between wp cpm generate reset and a real club's records — so don't.

Not the plugin's own, but the commands most often needed alongside it:

# What the plugin has scheduled, and whether cron is running at all
wp cron event list | grep -E 'cpm|efa'

# Drain the outgoing email queue now
wp cron event run cpm_process_email_queue

# Fetch fixtures and results now
wp cron event run efa_sync_matches

# Confirm the plugins are active and at the versions you expect
wp plugin list --status=active