2026年11月12日

2026年11月12日

How to Use Gravity Forms: Forms, Conditional Logic, Notifications

This article is a localized edition of the Japanese original. Read the Japanese original

Gravity Forms is a paid form plugin that is not distributed on WordPress.org. From the admin screen you can set up conditional logic that shows or hides fields, route notifications based on what was submitted, and store submissions (entries) in the database and export them. This article explains how to build a basic form and how developers can use its hooks. License details and screen labels were checked against the official Gravity Forms website and documentation as of November 2026. Screens are described with their English labels; if your admin is shown in another language, the wording may differ.

Licenses and available add-ons

The number of sites and the add-ons you can use depend on the license.

License Sites Main add-ons
Basic 1 Basic add-ons such as Mailchimp, HubSpot and reCAPTCHA
Pro 3 Everything in Basic, plus Stripe, PayPal Checkout, Square, Zapier, Slack and more
Elite Unlimited All add-ons (Webhooks, User Registration, Signature, Survey and more). Also supports Multisite

The Webhooks add-on, which sends submissions to external systems, is available only with Elite (and the nonprofit license). Stripe and PayPal Checkout payments require Pro or higher. Before buying, check on the official pricing page which license includes the add-ons you need.

Installing and registering the license key

Download the plugin ZIP file from your account page on the official Gravity Forms website, then install and activate it under "Plugins → Add New → Upload Plugin". With WP-CLI:

wp plugin install /path/to/gravityforms.zip --activate

Enter the license key on the "Forms → Settings" screen. To roll out the same setting to multiple environments, you can also define it as a constant in wp-config.php. When the constant is set, the license key field on the settings screen becomes read-only.

define( 'GF_LICENSE_KEY', 'YOUR-LICENSE-KEY-HERE' );

Create a form and place it on a page

  1. Open "Forms → New Form" in the admin area, give the form a name and create it.
  2. From "Add Fields" on the right, place fields such as Name, Email, Phone, Drop Down, Paragraph Text and Consent.
  3. Click a field to open its settings. Turn on "Required" for fields that must be filled in.
  4. Save with "Save Form".

To put the form on a page, add the "Gravity Forms" block in the block editor and select your form. To place it with a shortcode, use the following form, where id is the form ID shown in the form list.

[gravityform id="1" title="false"]

Show or hide fields with conditional logic

Rules such as "show the resume upload field only when the inquiry type is 'Careers'" are set with Conditional Logic.

  1. In the form editor, click the field you want to show or hide (for example, the resume file upload).
  2. Open "Conditional Logic" in the field settings and turn on "Enable Conditional Logic".
  3. Choose "Show" or "Hide", and whether "All" or "Any" of the conditions must be met.
  4. In the condition row, choose the source field (inquiry type), the comparison (is) and the value (Careers). Use the plus icon next to the row to add conditions.

Notifications and confirmations can each have their own conditional logic as well.

Set up notification emails

Notifications are configured under "Forms → your form → Form Settings → Notifications". When you create a form, one notification to the administrator is already set up. Use "Add New" to add more, such as an auto-reply.

Setting Content
Send To Recipient. "Enter Email" is a fixed address, "Select a Field" uses the form's email field, and "Configure Routing" picks the recipient based on what was entered
From Email Sender. Either {admin_email} (the administration email address under WordPress "Settings → General") or a fixed address
Reply To Reply address. In the notification to the administrator, putting the merge tag of the submitter's email field here makes replying easier
Subject / Message Subject and body. You can insert submitted values with merge tags

Merge tags are placeholders that insert submitted values. A field value uses the form {Label:Field ID} (for example {Name:1}; the label can be omitted, as in {:1}), and {all_fields} inserts all submitted values as a table. Choosing from the merge tag button at the top right of the message box lets you insert them without looking up field IDs.

Using a sender address on the same domain as your site makes it less likely the email is treated as spam. Avoid using the submitter's email address as the sender; put it in Reply To instead.

Confirmation after submission

What happens after submission is set under "Form Settings → Confirmations". There are three types:

  • Text: shows a message where the form was (the default)
  • Page: sends the user to a page on your site
  • Redirect: sends the user to a URL you specify

If you want a thank-you page for ad conversion or analytics tracking, choose Page or Redirect.

Add validation with PHP

For checks that the admin settings cannot handle, use the gform_field_validation filter. Adding _FormID_FieldID to the hook name applies it to that field only. The example below validates the phone number entered in field ID 3 of form ID 1. Put it in your theme's functions.php or in your own plugin.

<?php
// Validate the phone number in form ID 1, field ID 3
add_filter( 'gform_field_validation_1_3', function ( $result, $value, $form, $field ) {
	if ( ! is_string( $value ) || '' === $value ) {
		return $result; // Leave empty values to the field's "Required" setting
	}

	$digits = str_replace( array( '-', ' ' ), '', $value );

	if ( ! preg_match( '/^0\d{9,10}$/', $digits ) ) {
		$result['is_valid'] = false;
		$result['message']  = 'Enter a phone number of 10 or 11 digits starting with 0 (hyphens are allowed).';
	}

	return $result;
}, 10, 4 );

The form ID and field ID are shown when you select a field in the form editor. Recreating a form changes its ID, so check that the IDs match between production and development.

Notify an external service after submission

If your license has no Webhooks add-on and you want to notify Slack or another service on every submission, you can write the logic in the gform_after_submission action. This action runs after the entry is saved and notifications are sent. It also runs for entries marked as spam, so check the status before sending. With a Pro or higher license, you can also use the Slack or Zapier add-on instead.

<?php
// After form ID 1 is submitted, notify a Slack Incoming Webhook
add_action( 'gform_after_submission_1', function ( $entry, $form ) {
	if ( 'spam' === rgar( $entry, 'status' ) ) {
		return;
	}

	// Define the webhook URL in wp-config.php with define( 'MY_SLACK_WEBHOOK_URL', '...' );
	if ( ! defined( 'MY_SLACK_WEBHOOK_URL' ) ) {
		return;
	}

	wp_remote_post( MY_SLACK_WEBHOOK_URL, array(
		'headers' => array( 'Content-Type' => 'application/json' ),
		'body'    => wp_json_encode( array(
			'text' => sprintf( 'New inquiry: %s', rgar( $entry, '1' ) ),
		) ),
		'timeout' => 5,
	) );
}, 10, 2 );

rgar( $entry, '1' ) is the value of field ID 1. For fields with multiple inputs, such as Name, use IDs with a decimal point, like '1.3' (first name) and '1.6' (last name). The webhook URL is a secret, so do not write it directly in code or include it in a public repository.

View and export entries

Submissions are stored in the WordPress database and listed under "Forms → Entries". To export them as CSV, open "Forms → Import/Export", choose the form under "Export Entries", select the fields and date range, and download.

To read them from PHP, use GFAPI::get_entries(). This example shows the latest 10 entries with WP-CLI:

wp eval 'echo wp_json_encode( GFAPI::get_entries( 1, array(), null, array( "offset" => 0, "page_size" => 10 ) ) );'

Cautions

  • Submissions contain personal data. If you don't need to keep them, decide how they are handled, for example by setting a retention period in the form settings and deleting them, and not leaving exported CSV files lying around.
  • When notification emails don't arrive, the cause is often the server's mail sending rather than Gravity Forms. A plugin that sends mail through SMTP may help.
  • Before adding PHP code, confirm that the form ID and field ID are correct and test it on a staging environment.

Questions about WordPress? The publisher of this site is based in Japan and replies in Japanese. Contact (Japanese)

お気軽にご相談ください

お見積りへ お問い合わせへ
▲