In this article, we will show you how to do things such as import, export, update, delete, and even create forms using the CLI Add-On for Gravity Forms.
Creating Forms
wp gf form create
Examples
- Creates a new form with just a title and description.
wp gf form create 'My Form Title' 'Description Here'
Parameters
Argument | Description |
---|---|
<title> | The title of the new form. Overrides the title defined in the optional JSON. |
[<description>] | The description of the new form. Overrides the description defined in the optional JSON. |
[--form-json=<value>] | The JSON formatted form. |
[--porcelain] | If used, outputs just the created form ID instead of the standard success message. |
Deleting Forms
wp gf form delete
Examples
- Move form 5 to the trash.
wp gf form delete 5
- Permanently delete form 5.
wp gf form delete 5 --force
Parameters
Argument | Description |
---|---|
<form-id>... | One or more IDs of forms to be deleted. |
[--force] | Skips the trash and permanently deletes the form. |
Duplicating Forms
wp gf form duplicate
Examples
- Creates a duplicate copy of form 5.
wp gf form duplicate 5
Parameters
Argument | Description |
---|---|
<form-id> | The ID of the form to be duplicated. |
[--porcelain] | If used, outputs just the duplicate form ID instead of the standard success message. |
Editing Forms
wp gf form edit
Examples
- Launch the editor for form 5.
wp gf form edit 5
Parameters
Argument | Description |
---|---|
<form-id> | The ID of the form to be edited. |
Exporting Forms
wp gf form export
Examples
- Exports all forms to the current working directory.
wp gf form export
- Exports form 5 to a specific location.
wp gf form export 5 --dir=/my/custom/path
- Exports form 5 using a custom filename.
wp gf form export 5 --filename=testing.json
Parameters
Argument | Description |
---|---|
[<form-id>] | The ID of the form to export. If not set, exports all forms. |
[--dir='value'] | The path to the location that the export should be stored. Default: current working directory. |
[--filename='value'] | The filename for the form to export. Defaults to the current date. |
[--porcelain] | Overrides the standard success message with just the export file path. |
Listing Forms
wp gf form list
Examples
- Get a JSON formatted list of active forms sorted by id.
wp gf form list --active --sort_column=id --format=json
Parameters
Argument | Description |
---|---|
[--active] | List active forms. Default: true. |
[--trash] | List forms in trash. Default: false. |
[--sort-column=<value>] | The column to sort the list by. Accepted values: id, title, date_created, is_active, and is_trash. Default: id. |
[--sort-dir=<value>] | The direction to use when sorting. Accepted values: ASC or DESC. Default: ASC. |
[--format=<value>] | Defines the format in which the forms will be listed. Accepted values: table, csv, json, and count. Default: table. |
Getting Forms
wp gf form get
Examples
- Gets the JSON for form 5.
wp gf form get 5
Parameters
Argument | Description |
---|---|
<form-id> | The ID of the form to get. |
Importing Forms
wp gf form import
Examples
- Imports one or more forms from the supplied .json file.
wp gf form import /path/to/my/file.json
Parameters
Argument | Description |
---|---|
<json-path> | The path to a file containing the JSON formatted form(s) to be imported. |
Updating Forms
wp gf form update
Examples
- Updates form 5 using the supplied JSON string.
wp gf form update 5 --form-json='{snip}'
- Updates form 5 using the supplied .json file.
wp gf form update 5 --file='/path/to/my/file.json'
Parameters
Argument | Description |
---|---|
<form-id> | The ID of the form to update. |
[--form-json=<value>] | The JSON formatted form. |
[--file=<value>] | The path to a file containing the JSON formatted form. |