By using the CLI Add-On for Gravity Forms, you can easily manipulate entries using the command line. This article will show you the various commands available to you for managing entries.
Creating Entries
wp gf entry create
Examples
- Create a new entry from the entry 3 JSON.
wp gf entry create "$(wp gf entry get 3 --raw --format=json)"
- Create a new entry from field value pairs for form 1.
wp gf entry create 1 --field_1=ABC [email protected] --field_3=1234 --field_4=Hello --field_5.3=John --field_5.6=Doe
Parameters
Argument | Description |
---|---|
<entry-json> | JSON formatted entry. |
[<form-id>] | The ID of the form that the new entry should be associated with. |
[--<field>=<value>] | This allows you to associate values with specific fields within the entry. The field will be the the field ID, for example, field_4. The value will be the information that you would like to place within it, such as a text string. |
Deleting Entries
wp gf entry delete
Examples
- Move entry 5 to the trash.
wp gf entry delete 5
- Permanently delete entry 5.
wp gf entry delete 5 --force
- Move multiple entries to the trash.
wp gf entry delete 5 6 7
- Permanently delete trashed entries for form id 1.
wp gf entry delete $( wp gf entry list 1 --status=trash --format=ids ) --force
Parameters
Argument | Description |
---|---|
<entry-id> | The IDs of the entries to be deleted. |
[--force] | Skips the trash and permanently deletes the entries. |
Duplicating Entries
wp gf entry duplicate
Examples
- Create three duplicate copies of entry 5.
wp gf entry duplicate 5 --count=3
Parameters
Argument | Description |
---|---|
<entry-id> | The ID of the entry to be duplicated. |
[--count=<value>] | The number of times the entry should be duplicated. |
Editing Entries
wp gf entry edit
Examples
- Launch the editor for entry 5.
wp gf entry edit 5
Parameters
Argument | Description |
---|---|
<entry-id> | The ID of the entry to be edited. |
Exporting Entries
wp gf entry export
Examples
- Exports form 5 entries in json format to the specified location and filename.
wp gf entry export 5 myexport.json --dir=mydir --format=json
Parameters
Argument | Description |
---|---|
<form-id> | The ID of the form the entries are to be exported from. |
[<filename>] | The name of the export file you want to create. Default: form_title-date.format. |
[--dir=<value>] | The path to the location that the export should be stored. Default: current working directory. |
[--format=<value>] | Defines the format that the export should be in. Accepted values: csv or json. Default: csv. |
[--start_date=<value>] | Returns only entries submitted on or after the specified date. Accepted values: Date format yy-mm-dd. Default: Empty. |
[--end_date=<value>] | Returns only entries submitted up to and including the specified date. Accepted values: Date format yy-mm-dd. Default: The current system date. |
Returning Entries
wp gf entry get
Examples
- Get the raw values for entry 5 in json format.
wp gf entry get 5 --format=json --raw
Parameters
Argument | Description |
---|---|
<entry-id> | The ID of the entry to be obtained. |
[--format=<value>] | The format that the entry will be displayed in. Accepted values: table or json. Default: json. |
[--raw] | Displays the raw fields and values without formatting. This is best used as input for the create command. |
Importing Entries
wp gf entry import
Examples
- Imports one or more entries from the supplied .json file.
wp gf entry import 5 /path/to/file.json
Parameters
Argument | Description |
---|---|
<form-id> | The ID of the form the entries are to be imported into. |
<file> | The path to the file containing the JSON formatted entry. |
Listing Entries
wp gf entry list
Examples
- Get a table formatted list of up to twenty active entries for form 5.
wp gf entry list 5 --status=active
Parameters
Argument | Description |
---|---|
<form-id> | The ID of the form from which entries should be listed. |
[--status=<value>] | Only lists entries with a particular status. Accepted values: active or trash. Default: active. |
[--format=<value>] | The format in which the entries should be output. Accepted values: table, csv, json, and count. Default: table. |
[--page_size=<value>] | The number of entries to output. Default: 20. |
[--offset=<value>] | The number of entries to skip when outputting. Default: 0. |
Updating Entries
wp gf entry update
Examples
- Update entry 5 using the supplied JSON.
wp gf entry update 5 --entry-json='{"is_read":1}'
- Update entry 5 using the specified field and value pairs.
wp gf entry update 5 --field_1="My Value" --field_2="Another value"
Parameters
Argument | Description |
---|---|
<entry-id> | The ID of the entry to be updated. |
[--entry-json=<value>] | JSON formatted entry. Note: any values not defined will be replaced with null values. |
[--<field>=<value>] | This allows you to associate values with specific fields within the entry. The field will be the the field ID, for example, field_4. The value will be the information that you would like to place within it, such as a text string. |