Managing Gravity Forms and Add-Ons with WP-CLI

By using the CLI Add-On and the following root commands you can easily install and update Gravity Forms and official Add-Ons from the command line.

Installing Gravity Forms or an Add-On

wp gf install

Examples

# Using the install command without supplying a license key.
$ wp gf install
Error: A valid license key must be specified either in the GF_LICENSE_KEY constant or the --key option.
# Install Gravity Forms, replacing the installed version.
$ wp gf install --force
Downloading installation package from http://...
Unpacking the package...
Installing the plugin...
Removing the old version of the plugin...
Plugin updated successfully.
Success: Installed 1 of 1 plugins.
# Installing Gravity Forms using the specified license key.
$ wp gf install --key=abc123
Downloading installation package from http://...
Unpacking the package...
Installing the plugin...
Plugin installed successfully.
Success: Installed 1 of 1 plugins.
# Install the Gravity Forms Polls Add-On using the specified license key.
$ wp gf install gravityformspolls --key=abc123
Downloading installation package from http://...
Unpacking the package...
Installing the plugin...
Plugin installed successfully.
Success: Installed 1 of 1 plugins.
# Using an invalid add-on slug or license key.
$ wp gf install something --key=abc123
Error: There was a problem retrieving the download URL, please check the key.

Parameters

ArgumentDescription
[<slug>]The plugin slug.
Accepted values: gravityforms or a Gravity Forms Add-On slug.
Default: gravityforms.
[--key=<value>]A valid Gravity Forms license key.
[--version=<value>]The version to be installed.
Accepted values: auto-update, hotfix, or beta.
Default: hotfix.
[--force]Overwrites the installed version of the plugin, without prompting for confirmation.
[--activate]Activates the plugin immediately after install.
[--activate-network]Network activates the plugin immediately after install.

Updating Gravity Forms or an Add-On

wp gf update

Examples

# Attempting to update without Gravity Forms being active.
$ wp gf update
Error: Gravity Forms is not active.
# Attempting to update Gravity Forms without a license key.
$ wp gf update
Error: A valid license key must be saved in the settings or specified in the GF_LICENSE_KEY constant or the --key option.
# Attempting to update Gravity Forms when an update is not available.
$ wp gf update
Success: Plugin already updated
# Successfully updating Gravity Forms using the specified license key.
$ wp gf update --key=abc123
Downloading installation package from http://...
Unpacking the package...
Installing the plugin...
Removing the old version of the plugin...
Plugin updated successfully.
Success: Installed 1 of 1 plugins.
Success: Database upgraded.
# Successfully updating the Gravity Forms Polls Add-On.
$ wp gf update gravityformspolls
Downloading installation package from http://...
Unpacking the package...
Installing the plugin...
Removing the old version of the plugin...
Plugin updated successfully.
Success: Installed 1 of 1 plugins.
Success: setup gravityformspolls

Parameters

ArgumentDescription
[<slug>]The plugin slug.
Accepted values: gravityforms or a Gravity Forms Add-On slug.
Default: gravityforms.
[--key=<value>]A valid Gravity Forms license key.
[--version=<value>]The version to be installed.
Accepted values: auto-update, hotfix, or beta.
Default: hotfix.

Running the Database Setup

wp gf setup

Examples

# Successfully running the database setup for a new install.
$ wp gf setup
Success: setup gravityforms
# Failing to run the database setup for an existing install.
$ wp gf setup
Error: Use the --force flag to force the database setup.
# Successfully running the database setup for an existing install.
$ wp gf setup --force
Success: Database upgraded.
# Successfully running the database setup for the Gravity Forms Polls Add-On.
$ wp gf setup gravityformspolls
Success: setup gravityformspolls
# Forcing the setup on a multisite network
$ for url in $(wp site list --fields=url --format=csv | tail -n +2); do echo Running setup for site:  $url; wp gf setup --force --url=$url; done
Running setup for site: https://one.site.local/
Success: Database upgraded.
Running setup for site: https://two.site.local/
Success: Database upgraded.

Parameters

ArgumentDescription
[<slug>]The plugin slug.
Accepted values: gravityforms or a Gravity Forms Add-On slug.
Default: gravityforms.
[--force]Runs the setup regardless of whether it has been run before.

Checking for Updates

wp gf check-update

Examples

# Successfully getting the available Gravity Forms versions.
$ wp gf check-update
+-------------+---------+
| type        | version |
+-------------+---------+
| auto-update | 2.3     |
| hotfix      | 2.3.0.4 |
+-------------+---------+
# Successfully getting the available Gravity Forms Polls Add-On versions in yaml format.
$ wp gf check-update gravityformspolls --format=yaml
---
-
  type: auto-update
  version: 3.1
-
  type: hotfix
  version: 3.1.4

Parameters

ArgumentDescription
[<slug>]The plugin slug.
Accepted values: gravityforms or a Gravity Forms Add-On slug.
Default: gravityforms.
[--format=<value>]Defines the format in which the updates will be listed.
Accepted values: table, csv, json, yaml, and count.
Default: table.

Getting the Version

wp gf version

Examples

# Attempting to get the version when Gravity Forms is not installed.
$ wp gf version
Error: Gravity Forms is not installed. Use the wp gf install command.
# Successfully getting the Gravity Forms version.
$ wp gf version
2.3.0.4
# Attempting to get the add-on version using an invalid slug.
$ wp gf version something
Error: Invalid plugin slug: something
# Successfully getting the Gravity Forms Polls Add-On version.
$ wp gf version gravityformspolls
3.1.4

Parameters

ArgumentDescription
[<slug>]The plugin slug.
Accepted values: gravityforms or a Gravity Forms Add-On slug.
Default: gravityforms.