WP-CLI Commands
WP-CLI Commands
Section titled “WP-CLI Commands”Learnomy adds a wp learnomy command group. It is useful for the jobs that are painful in the browser: enrolling a list of people, checking why one student’s progress looks wrong, repairing data after an import, and migrating from another LMS.
Everything here runs on your own server over SSH or a local shell. If you have never used WP-CLI, the only thing you need to know is that commands run from your WordPress directory.
Run commands as an administrator
Section titled “Run commands as an administrator”Several commands check that the person running them may do the thing being asked. WP-CLI has no logged-in user, so those checks fail with a permissions error unless you say who you are:
wp --user=1 learnomy enroll --user-id=42 --course=17Use --user=1 (or any administrator’s ID) on anything that writes. Read-only commands like stats and inspect do not need it.
Everyday commands
Section titled “Everyday commands”Enrolling and unenrolling
Section titled “Enrolling and unenrolling”wp --user=1 learnomy enroll --user-id=42 --course=17wp --user=1 learnomy enroll --user-id=42 --course=17 --source=manualwp --user=1 learnomy unenroll --user-id=42 --course=17--source records how the enrollment happened. Leave it off unless you are reproducing a purchase.
Checking one learner
Section titled “Checking one learner”wp learnomy progress --user-id=42 --course=17wp learnomy earnings --user-id=7progress prints where a student has got to in a course, which is the fastest answer to “the site says I have not finished”. earnings does the same for an instructor’s revenue share.
Site overview
Section titled “Site overview”wp learnomy statsCounts across courses, students, enrollments and revenue. Useful as a before-and-after when you have run something that changes data in bulk.
Looking things up
Section titled “Looking things up”inspect prints one record in full, which is quicker than clicking through the admin when you are chasing a specific problem.
wp learnomy inspect course 17wp learnomy inspect user 42wp learnomy inspect enrollment 512wp learnomy inspect quiz 8wp learnomy inspect attempt 91wp learnomy inspect cert 30wp learnomy inspect subscription 14wp learnomy inspect transaction 260wp learnomy inspect dbFixing data
Section titled “Fixing data”Repair
Section titled “Repair”wp learnomy repair data-integrity --dry-runwp learnomy repair data-integritywp learnomy repair lesson-contentwp learnomy repair student-countdata-integrity is the one to reach for after an import or a bulk delete. It finds orphaned rows, drifted counters and progress that no longer matches the curriculum, and reports what it would change. Always run it with --dry-run first and read the report before letting it write.
student-count recomputes the enrolled figure shown on course cards when it has drifted. lesson-content repairs lesson bodies left malformed by an older import.
Cleanup
Section titled “Cleanup”wp learnomy cleanup orphan-enrollments --dry-runwp learnomy cleanup orphan-certswp learnomy cleanup orphan-commissionsRemoves rows whose parent is gone. Same rule: dry-run first.
Modules
Section titled “Modules”wp learnomy module listwp learnomy module info membershipwp learnomy module enable membershipwp learnomy module disable pwaMost Learnomy features are modules, and several ship switched off. This is the scriptable equivalent of the Modules screen, which is handy when you set up sites repeatedly. See Enabling Features and Modules.
Content
Section titled “Content”wp learnomy course listwp learnomy course create --title="Course title" --author_id=7wp learnomy course delete 17 --yes
wp learnomy membership listwp learnomy membership create --name="Pro" --price=19 --interval=monthlySnapshots before a risky change
Section titled “Snapshots before a risky change”wp learnomy content snapshotwp learnomy content restorewp learnomy content migratesnapshot saves lesson content before a migration so restore can put it back. Take one before any bulk content operation you have not run on this site before.
Migrating from another LMS
Section titled “Migrating from another LMS”wp learnomy migrate previewwp learnomy migrate runwp learnomy migrate statuswp learnomy migrate runswp learnomy migrate undopreview reports what would be imported without writing anything. runs lists past imports and status reports on one; undo reverses an import that went wrong, which is the reason to prefer the CLI over the browser importer on a site with real data.
The browser importer covers the same ground with a UI. Use the CLI version for very large sites, where a browser import can time out. See Migrating from Another LMS.
Exports
Section titled “Exports”Three types are available: courses, students and earnings.
wp learnomy export students --file=/tmp/students.csvwp learnomy export courses --file=/tmp/courses.csvwp learnomy export earnings --file=/tmp/earnings.csvHealth checks
Section titled “Health checks”wp learnomy selfcheck runwp learnomy db migrateselfcheck run verifies the install: tables present, routes registered, scheduled jobs in place. Run it after an update if something feels wrong. db migrate applies any pending schema change, which normally happens automatically on update.
Attachment protection
Section titled “Attachment protection”wp learnomy protect-attachments --dry-runwp learnomy protect-attachmentsMoves lesson attachments behind a permission check so a direct URL cannot be shared outside the course.
Commands that are not on your install
Section titled “Commands that are not on your install”seed, seed-cleanup, seed-model-site, seed-quiz-attempts, seed-usecase and test are development and demo tools. They live in a directory that is stripped from the distributed plugin, so they will not appear on a normal install. If you see them, you are on a development checkout.

