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 a line such as GravityKit Foundation 1.37.0 (loaded by GravityView).
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 | 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 |
| DataTables | gv-datatables |
| DIY Layout | gravityview-diy |
| GravityMaps (listed as Maps Premium View) | gk-gravitymaps |
| Dashboard Views | gk-gravityview-dashboard-views |
| Multiple Forms | gravityview-multiple-forms |
| Advanced Filtering | gravityview-advanced-filter |
| A-Z Filters | gravityview-az-filters |
| Magic Links | gk-gravityview-magic-links |
| Advanced Elementor Widget | gk-gravityview-elementor |
| Featured Entries | gravityview-featured-entries |
| Ratings & Reviews | gravityview-ratings-reviews |
| Social Sharing & SEO | gravityview-sharing-seo |
| 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.
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, Update Available, Licensed, Installed, Active, and Network Active. Version is the installed version, or the latest version for a product that isn’t installed.
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 --activateUpdate products
# Update one product
wp gk products update gk-gravityview
# Update several products
wp gk products update gk-gravityview,gk-gravitymaps
# 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 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. With --all, it also tries the products that aren’t installed and reports each of them as failed.
Without --skip-dependency-check, the deactivate command stops when other active products need the one you’re deactivating, and it lists them.
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-deletionLicense 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 wp gk licenses activate command can’t do this step, because the keys are already saved on the site.
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. Free it on the Licenses page of your GravityKit account by clicking the × next to its address, or run wp gk licenses deactivate on the old site.
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, and check 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. If its status on the Manage Your Kit page is Not Activated for This Site, for example after a move to a new address, click Activate on its row there.
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.
A command leaves the product unchanged
Check the text domain’s spelling. Product commands skip an unknown text domain without an error message.