bookmark_borderManaging Fields with WP-CLI

When using the CLI add-on for Gravity Forms, you are able to easily manage your forms using only the command line, via WP-CLI. In this article, we will show you how to do things such as update, delete, and even create forms using WP-CLI.

Creating Fields

Example

wp gf field create 1 text 'My Text Field'

Parameters

  • form-id
    The ID of the form to create a field in.

  • type
    The type of field to create. Examples: text, textarea, email

  • label
    The label to associate with the created field.

  • –field-json=
    Allows defining these values as JSON rather than the default parameters.

Deleting Fields

Example

wp gf field delete 5 2

Parameters

  • form-id
    The ID of the form that a field will be deleted from.

  • field-id
    The ID of the field to be deleted.

Duplicating Fields

Example

wp gf field duplicate 5 2

Parameters

  • form-id
    The ID of the form that a field will be duplicated in.

  • field-id
    The ID of the field to be duplicated.

Editing Fields

Example

wp gf field edit 5 2

Parameters

  • form-id
    The ID of the form that contains the field you want to edit.

  • field-id
    The ID of the field you want to edit.

Getting Fields

Example

wp gf field get 5 2

Parameters

  • form-id
    The ID of the form that contains the field you want to view.

  • field-id
    The ID of the field you want to view.

Listing Fields

Example

wp gf field list 5

Parameters

  • form-id
    The ID of the form that you want to list fields from.

Updating Forms

Example

wp gf field update 5 2 --field-json={key:"value"}

Parameters

  • form-id
    The ID of the form that contains the field that will be updated updated.

  • field-id
    The ID of the field that will be updated.

  • –field-json-
    A JSON representation of the field information.