Managing GravityKit products and licenses with WP-CLI
GravityKit adds wp gk commands to WP-CLI, the command-line tool for WordPress. Use them to manage GravityKit products and license keys from a terminal, for example in a deployment script.
To manage GravityKit products with Composer instead, see Installing GravityKit Products via Composer.
Prerequisites #
- WP-CLI installed on your server.
- GravityView, or another GravityKit plugin that includes GravityKit Foundation, active on the site. Foundation is the part that adds the GravityKit menu to the dashboard and the
wp gkcommands to WP-CLI. - A GravityKit license, to install and update paid products. Free products don’t need one.
To check that the commands are available, run wp gk version. It prints the GravityKit Foundation version and the plugin that loaded it, such as GravityView Pro.
Product text domains #
Product commands identify each product by its text domain, a unique slug. The Text Domain column of wp gk products list shows the current list.
| Product | Text domain |
|---|---|
| GravityView Pro or GravityView | gk-gravityview |
| GravityActions | gk-gravityactions |
| GravityBoard | gk-gravityboard |
| GravityCalendar | gk-gravitycalendar |
| GravityCharts | gk-gravitycharts |
| GravityEdit | gk-gravityedit |
| GravityExport | gk-gravityexport |
| GravityImport | gk-gravityimport |
| GravityMath | gk-gravitymath |
| GravityMigrate | gk-gravitymigrate |
| GravityRevisions | gk-gravityrevisions |
| GravitySearch | gk-gravitysearch |
| GravityExport Lite (free) | gk-gravityexport-lite |
| Gravity Forms Zero Spam (free) | gravity-forms-zero-spam |
| Gravity Forms Dynamic Lookup (free) | gk-gravity-forms-dynamic-lookup |
| Gravity Forms Entry Tags (free) | gk-entry-tags |
| Gravity Forms Event Field (free) | gk-event-field |
| Gravity Forms Widget for Elementor (free) | gk-gravity-forms-elementor-widget |
| Block MCP (free) | gk-block-mcp |
To act on several products at once, separate their text domains with commas and no spaces:
wp gk products install gk-gravityview,gk-gravitycharts,gk-gravityexport --activateThird-party products sold by GravityKit, such as PDF for GravityView and Image Hopper, aren’t available to these commands.
Features built into GravityView Pro
In wp gk products list, each of these GravityView Pro features has its own text domain. Their Installed and Active columns describe a separate copy of the feature, so they stay empty while only the built-in copy is there, and --only-installed leaves the feature out.
| Feature (as the list names it) | Text domain |
|---|---|
| Advanced Elementor Widget | gk-gravityview-elementor |
| Advanced Filtering | gravityview-advanced-filter |
| A-Z Filters | gravityview-az-filters |
| Dashboard Views | gk-gravityview-dashboard-views |
| DataTables | gv-datatables |
| DIY Layout | gravityview-diy |
| Featured Entries | gravityview-featured-entries |
| Gravity Forms Dynamic Lookup | gk-gravity-forms-dynamic-lookup |
| Gravity Forms Entry Tags | gk-entry-tags |
| Gravity Forms Event Field | gk-event-field |
| Magic Links | gk-gravityview-magic-links |
| Maps Premium View | gk-gravitymaps |
| Multiple Forms | gravityview-multiple-forms |
| Ratings & Reviews | gravityview-ratings-reviews |
| Social Sharing & SEO | gravityview-sharing-seo |
To turn a built-in feature on or off, go to Plugins and click Features in the GravityView Pro row. The product commands act on separate copies of these features:
- With no separate copy installed,
wp gk products activate gravityview-az-filtersstops with “A-Z Filters is not installed” and suggestswp gk products install. You don’t need to install it, since the built-in copy already runs. - A separate copy that you install and activate runs instead of the built-in copy. When you deactivate it, the built-in copy runs again, unless the feature is turned off on the Features screen.
To switch off and delete separate copies from a terminal, use the commands in Separate copies and editions. Moving from separate extensions to GravityView Pro explains how to remove them from the dashboard.
On a GravityView + Extensions (Legacy) license, these features are separate plugins. About the “GravityView + Extensions (Legacy)” license shows how to install them.
Product commands #
List products
# All products, licensed or not
wp gk products list
# Installed products only
wp gk products list --only-installed
# Licensed and free products only
wp gk products list --exclude-unlicensed
# JSON output, for scripts
wp gk products list --format=json
# Fetch the list from GravityKit instead of using the 12-hour cache
wp gk products list --skip-cacheThe table has these columns: Name, Description, Text Domain, Version, Edition, Update Available, Licensed, Installed, Active, and Network Active. Version is the installed version, or the latest version for a product that isn’t installed. For GravityView Pro, Edition reads Pro.
Search products
The search matches product names, text domains, and descriptions.
wp gk products search "import"
wp gk products search gravity --format=jsonInstall products
Paid products need a license that covers them. Free products, such as Gravity Forms Zero Spam, install without one.
# Install one product
wp gk products install gk-gravityexport
# Install and activate
wp gk products install gk-gravityexport --activate
# Install several products
wp gk products install gk-gravityimport,gk-gravitycharts --activate
# Install every product your licenses cover, plus all free products
wp gk products install --all --activateOn a site with GravityView Pro, --all skips the features that GravityView Pro includes and prints a line for each, such as Skipping A-Z Filters: GravityView Pro includes it.
Update products
# Update one product
wp gk products update gk-gravityview
# Update several products
wp gk products update gk-gravityview,gk-gravitycharts
# Update every installed product that has an update
wp gk products update --all
# Skip the dependency check for the new version
wp gk products update gk-gravityview --skip-dependency-checkBefore updating, the command checks the new version’s PHP, WordPress, and plugin requirements. If one isn’t met, it skips that product and lists what’s missing.
The command also skips a product whose folder is a Git repository. Add --skip-git-check to update it anyway, which overwrites the folder.
WordPress turns a plugin off while it replaces the plugin’s files. The command turns each product that was active back on and prints a line such as Success: GravityView Pro reactivated. If it can’t, it prints the wp plugin activate command to run.
Activate and deactivate products
# Activate a product
wp gk products activate gk-gravityview
# Activate every installed product that is inactive
wp gk products activate --all
# Deactivate a product
wp gk products deactivate gk-gravitycalendar
# Deactivate a product even if other active products need it
wp gk products deactivate gk-gravityview --skip-dependency-checkThe activate command checks the product’s requirements first, the same way the update command does.
Without --skip-dependency-check, the deactivate command stops when an active product needs the one you’re deactivating.
For example, while a separate DIY Layout plugin is active, wp gk products deactivate gk-gravityview stops with Error: GravityView Pro is required by other products. Please deactivate them first. It then lists DIY Layout with its text domain, and GravityView Pro stays active.
Delete products
# Delete a product (deactivate it first)
wp gk products delete gk-gravityimport
# Deactivate and delete in one step
wp gk products delete gk-gravityimport --deactivate-before-deletion
# Delete all installed products
wp gk products delete --all --deactivate-before-deletionSeparate copies and editions #
Switch off separate copies of built-in features
After a site moves to GravityView Pro, the separate plugins of its built-in features can stay installed. wp gk products switch-to-bundled switches them off, so GravityView Pro runs its built-in copies. It acts on the copies that the review in Manage Your Kit ticks for removal.
# List the separate copies, then switch them off
wp gk products switch-to-bundled
# Switch them off and get the command that deletes their files
wp gk products switch-to-bundled --delete
# Skip the confirmation question
wp gk products switch-to-bundled --delete --yesThe command lists each separate copy it found, with its path, its version, and the version GravityView Pro includes. The Action column says what happens to each copy:
Switch off: the copy is deactivated, and its files stay.Switch off and delete: with--delete, the copy is deactivated now, anddelete-supersededdeletes its files afterwards.Leave alone: the copy stays as it is, and the Note column says why. For example, an active support build is kept with the noteYour copy (3.0-f0962fa) is a support build made for this site. Keep it until GravityKit support says you can remove it.
Then the command asks for confirmation, such as Switch off 2 copies? [y/n]. Type y to go ahead.
Each copy then gets a line such as Success: DIY Layout was switched off. Its files are still there. GravityView Pro runs its built-in copy now.
The command has no option to choose copies, so it acts on every copy that isn’t marked Leave alone. To switch off one copy at a time, use its links on the Plugins screen, as Moving from separate extensions to GravityView Pro describes.
Delete switched-off copies
With --delete, switch-to-bundled switches the copies off and leaves their files, because the running command still has their code loaded. It ends by printing the delete-superseded command to run next, with the paths of those copies.
# Delete the files of every switched-off copy that can be deleted
wp gk products delete-superseded
# Delete the files of one copy, by the path that switch-to-bundled lists
wp gk products delete-superseded gravityview-diy/gravityview-diy.phpBefore it deletes anything, the command names the copies and asks for confirmation. Add --yes to skip the question.
Each deleted copy gets a line such as Success: DIY Layout was switched off and deleted. GravityView Pro runs it now.
Switch GravityView between editions
wp gk products switch-edition changes a product to another edition. For GravityView, --to=pro means GravityView Pro and --to=core means GravityView.
# Switch GravityView to GravityView Pro
wp gk products switch-edition gk-gravityview --to=pro
# Switch GravityView Pro to GravityView
wp gk products switch-edition gk-gravityview --to=coreThe switch installs a download that GravityKit sends for your site. GravityKit sends the download for GravityView only when your license no longer includes GravityView Pro, or when GravityKit support sets it up for your site.
When there is no download, the command stops and changes nothing. Click Refresh on the Manage Your Kit page and run the command again. If it still stops and you need to switch, you can contact GravityKit support.
Before a switch to GravityView, the command also stops when a feature in use would be lost because its separate plugin isn’t installed.
Show edition details for support
wp gk products edition-status shows which edition of a product is installed and what GravityKit last answered about it for your licenses. GravityKit support may ask you to run it and send the output. License keys never appear in it, since each license shows as a 16-character code.
# Every product that comes in editions
wp gk products edition-status
# One product, as JSON
wp gk products edition-status gk-gravityview --format=json
# Check the licenses with GravityKit first, then show the answers
wp gk products edition-status gk-gravityview --recheckThe table for each product shows the installed copy and its edition, other copies, the editions the site has run, the saved answers for each license, and the update the product would take. Below it, This site as the Store sees it: shows the address each license is saved for and the time of the last license check.
Without --recheck, the command only reads what is saved on the site. With it, the command first asks GravityKit to check your licenses, and its first line says so.
License commands #
List licenses
# Licenses saved on this site
wp gk licenses list
# Fetch fresh license data from GravityKit first
wp gk licenses list --skip-cache
# JSON output
wp gk licenses list --format=jsonThe table has these columns: Name, Email, Type, Key, Expiry, Limit, Site Count, Activations Left, and Scope. Key shows the full license key, and Expiry is a Unix timestamp or lifetime. On Multisite, Scope shows whether a license covers one site or the whole network.
Check license keys
The check command looks up keys on the GravityKit server and shows the same columns as licenses list. It doesn’t activate anything.
# Check one key
wp gk licenses check YOUR_LICENSE_KEY
# Check several keys, as JSON
wp gk licenses check KEY1,KEY2 --format=jsonAn unknown key prints Error: License YOUR_LICENSE_KEY is invalid. With --format=json, each key’s result prints on its own line.
Activate and deactivate licenses
# Activate a key on this site
wp gk licenses activate YOUR_LICENSE_KEY --url=https://example.com
# Activate several keys
wp gk licenses activate KEY1,KEY2 --url=https://example.com
# Deactivate a key on this site
wp gk licenses deactivate YOUR_LICENSE_KEY --url=https://example.comBoth commands stop unless you pass --url with the site’s address. Deactivating releases this site’s activation, so you can use it on another site.
On WordPress Multisite, --url picks the site, and the activate command takes a --scope option:
# Activate for one site only
wp gk licenses activate YOUR_LICENSE_KEY --url=https://site1.example.com --scope=site
# Activate for the whole network
wp gk licenses activate YOUR_LICENSE_KEY --url=https://example.com --scope=networkWithout --scope, a Multisite activation covers the whole network, and the command shows a warning that says so. See Multisite and GravityKit licenses for how the two scopes differ.
Restoring licenses after a site move #
On a site connected to your GravityKit account, click Reconnect on the Manage Your Kit page if it appears after the move. It appears when the connection can no longer be used, for example after the move changed the site’s secret keys. Managing connected sites describes the steps.
For keys entered by hand, what to do depends on whether the new site can still read the licenses saved in its database.
The new site can read the saved licenses
The new site can read them when it uses the same WordPress secret keys (salts) as the old site, or the same GRAVITYKIT_SECRET_KEY. If you replace wp-config.php during the move and the old file defines GRAVITYKIT_SECRET_KEY, copy that line into the new file.
At the same address, there’s nothing else to do. At a new address, click Refresh on the Manage Your Kit page, then click Activate on each license that reads Not Activated for This Site or Not Activated.
The new site can’t read the saved licenses
The new site can’t read them when the move changed the secret keys. wp gk licenses list then reports Error: No licenses found., and The license key keeps disappearing explains why. Copy your keys from the Licenses page of your GravityKit account and activate them again:
wp gk licenses activate KEY1,KEY2 --url=https://example.comActivating a key again at the same address doesn’t use another activation. Keys you hard-coded in wp-config.php come back by themselves.
Free the old site’s activation
If the old site stays online at a different address, it still holds an activation for each license. To free it, use one of these:
- On the Licenses page of your GravityKit account, click the × next to the old site’s address.
- On the old site, run
wp gk licenses deactivate YOUR_LICENSE_KEY --url=https://old.example.comwith that site’s address.
Automation examples #
Update all products every night
Add this line to the server’s crontab. Use the full path to wp, which which wp prints.
# Update all GravityKit products every night at 3 a.m.
0 3 * * * cd /path/to/wordpress && /usr/local/bin/wp gk products update --allDeployment script
#!/bin/bash
# Activate the license on this site
wp gk licenses activate YOUR_LICENSE_KEY --url=https://example.com
# Install and activate the products this site uses
wp gk products install gk-gravityview,gk-gravityexport --activateCheck for updates in a script
# List installed products that have an update.
# tail -n1 skips the "Found N products:" line.
wp gk products list --only-installed --format=json | tail -n1 \
| jq '.[] | select(.update_available != "") | {name, version, update_available}'Output formats #
The list, search, check, and edition-status commands accept --format=table, the default, or --format=json. The list and search commands print a summary line such as Found 31 products: before the results. When you pipe JSON to a tool like jq, add tail -n1 to skip that line.
Troubleshooting #
WP-CLI says gk isn’t a registered command
Activate GravityView or another GravityKit plugin that includes GravityKit Foundation. Gravity Forms Zero Spam doesn’t include it.
No licenses found
No license is saved on this site. Activate one on the Manage Your Kit page or with wp gk licenses activate. If the site had licenses before, see The license key keeps disappearing.
This license is already activated
The key is already saved on this site, and wp gk licenses list shows it.
Activation limit reached
The license is active on as many sites as it allows. Deactivate a site you no longer use from your GravityKit account, or contact support. Development sites don’t count toward the limit, as described in Development websites and GravityKit licenses.
A product shows as not licensed
Your licenses may not cover it, or the license may have expired. Run wp gk licenses list --skip-cache to fetch fresh license data.
The dependency check blocks a product
When you update or activate a product, the command checks that the server has what the product needs, such as a newer PHP or WordPress version or another plugin, and lists what’s missing. Resolve those first. We don’t recommend --skip-dependency-check on a live site.
When you deactivate a product that an active product needs, the command names the products that need it. Deactivate those first.
A command says a text domain is not found
The text domain is misspelled, or it isn’t a GravityKit product. The command prints an error such as Error: gk-gravityexprot not found. and changes nothing. Copy the text domain from the Text Domain column of wp gk products list.
