Managing Form Notifications with WP-CLI

By using the CLI Add-On for Gravity Forms, you can easily manage form notifications using the command line.

Pre-Requisites

Listing Form Notifications

wp gf form notification list

Examples

  • Outputs a table listing the notifications for form 1.

    wp gf form notification list 1

  • Outputs a table listing the active notifications for form 1.

    wp gf form notification list 1 --active

  • Outputs the raw properties for the form 1 notifications.

    wp gf form notification list 1 --raw

Parameters

ArgumentDescription
<form-id>The ID of the form to retrieve the notifications from.
[--active]Retrieves only active notifications.
[--format=<value>]Defines the format in which the notifications will be listed.
Accepted values: table, ids, csv, json, yaml, and count.
Defaults to table.
[--raw]Outputs the raw notification properties as a JSON string.

Creating Form Notifications

wp gf form notification create

Examples

  • Creates a new notification for form 1 with the specified name.

    wp gf form notification create 1 'My Notification'

  • Creates a new notification for form 1 with the specified name and to address.

    wp gf form notification create 1 'My Notification' --to='[email protected]'

Parameters

ArgumentDescription
<form-id>The ID of the form to create the notification for.
[<name>]The name to be assigned to the new notification.
[--to=<value>]The to field value.
Default: {admin_email}.
[--subject=<value>]The subject field value.
Default: New submission from {form_title}.
[--message=<value>]The message field value.
Default: {all_fields}.
[--to-type=<value>]The send to type field value.
Default: email.
[--event=<value>]The event field value; when the notification will be sent.
Default: form_submission.
[--notification-json=<value>]The JSON formatted notification.
[--porcelain]Outputs just the notification ID instead of the standard success message.

Getting Form Notifications

wp gf form notification get

Examples

  • Gets the JSON for the specified notification from form 1.

    wp gf form notification get 1 596e4794a13a2

Parameters

ArgumentDescription
<form-id>The ID of the form to get the notification from.
<notification-id>The ID of the notification to get.

Deleting Form Notifications

wp gf form notification delete

Examples

  • Deletes the specified form 1 notification.

    wp gf form notification delete 1 596e4794a13a2

  • Deletes the specified form 1 notifications.

    wp gf form notification delete 1 596e4794a13a2 574ff8257d864

Parameters

ArgumentDescription
<form-id>The ID of the form to delete the notification from.
<notification-id>...The IDs of the notification to delete.

Duplicating Form Notifications

wp gf form notification duplicate

Examples

  • Duplicates the specified form 1 notification.

    wp gf form notification duplicate 1 596e4794a13a2


Parameters

ArgumentDescription
<form-id>The ID of the form to duplicate the notification for.
<notification-id>The ID of the notification to duplicate.
[--porcelain]Outputs just the new notification ID instead of the standard success message.

Updating Form Notifications

wp gf form notification update

Examples

  • Updates the specified form 1 notification from the supplied JSON.

    wp gf form notification update 1 --notification-json='{snip}'

  • Updates the specified notification using the supplied JSON.

    wp gf form notification update 1 abc1 --notification-json='{snip}'

Parameters

ArgumentDescription
<form-id>The ID of the form to update the notification for.
[<notification-id>]The ID of the notification to be updated.
[--notification-json=<value>]The JSON formatted notification.

Editing Form Notifications

wp gf form notification edit

Examples

  • Launch the editor for the specified form notification.

    wp gf form notification edit 1 596e4794a13a2


Parameters

ArgumentDescription
<form-id>The ID of the form the notification to be edited belongs to.
<notification-id>The ID of the notification to edit.