Conditional Logic in Gravity Forms Confirmations

Conditional Logic in Gravity Forms Confirmations

IntroductionRequirementUsage NotesHow To Setup A Conditional Confirmation

Introduction

Sometimes you may want to send a user to a different page or display different information to them based on what they submit within the form. In this article, we will show you how to use conditional logic within your form confirmation options you can display information to users that is dependent on their selections within the form submission.

Requirement

This article assumes that you have already created your form, as well as created an additional confirmation message.

Usage Notes

A default confirmation is established automatically at the creation of every new form.Conditional logic is only available in confirmations you create, and is not available for the default confirmation.The default confirmation cannot be turned off. This is intended to always ensure one confirmation can execute. The default confirmation will execute only if no other confirmation is executed.If a form submission would trigger multiple active conditional confirmations, then only the first one will be executed.

How To Setup A Conditional Confirmation

Within your form confirmations page, at the bottom, you should notice a heading labeled Conditional Logic.The first field you will see is a dropdown in which you can switch between All and Any. Setting this to All will require all rules to match before the confirmation is executed. Conversely, setting it to Any will only require one of the rules to match.Below this, you will see another set of fields. The first field will list the form field name, the second field is the comparison operator, and the third field is the value. For example, if you wanted to show a different confirmation for users that selected a particular radio button, you would select the field that contains the radio buttons, then is, and finally the individual radio button option that you want to base the confirmation on. In this scenario, users will receive the custom confirmation only if the particular radio button First Choice is selected.If you want to add additional conditions, simply press, the 「+」 button to the right of your first condition.

Chained Selects Field

Chained Selects Field

SummaryCommon SettingsAppearanceMore InformationMerge TagsUsageModifiers

Summary

The Chained Selects field is available when using the Chained Selects Add-On. With the proper setup, this field will allow you to create selection fields that will dynamically change based on the previous selection, this creating a cascade of dependent field choices.

Chained Select field as displayed in the Field Library

Example view in the Form Editor

How it would look in Form Preview

Common Settings

This field uses mostly common field settings for the General, Appearance, and Advanced settings. For a description of each of the common field settings, refer to this article. Below you will find descriptions of specialty settings that are particular to this field.

Appearance

SettingDescriptionDrop Down AlignmentSets the alignment of how the chained selects will be displayed (horizontally or vertically).Drop Down DisplayAllows the hiding of inactive dropdowns. If this option is enabled, dropdowns in subsequent steps will only be shown if the prior step has been selected.

More Information

For the process of creating and populating the data for a chained select field, refer to this help guide.

Merge Tags

Usage

{Field Name:2}

Notes:

The first of the merge tag parameters above, Field Name, is optional and is simply the field name for easier identification.The second parameter defines the field ID within the form. In the example above, it would be field ID 2.If accessing a specific option within the field, it can be accessed by separating the values with a period. For example, 2.3 would be the value of the 3rd choice from field ID 2.

Modifiers

This field does not have any modifiers.

Confirmation Object

Confirmation Object

IntroductionUsageProperties

Introduction
The Confirmation object contains the form confirmation settings such as confirmation text or redirect URL. It is defined as an associative array.
Usage
$form["confirmation"]["type"]; // returns the confirmation type
$form["confirmation"]["message"]; // returns the confirmation message

Properties

type string
Determines the type of confirmation to be used. Possible values: message, page, redirect

message: displays a simple message
page: redirects to a WordPress page
redirect: redirects to an exterior page

message string
Contains the confirmation message that will be displayed. Only applicable when type is set to message.

pageId string
Contains the Id of the WordPress page that the browser will be redirected to. Only applicable when type is set to page.

url string
Contains the URL that the browser will be redirected to. Only applicable when type is set to redirect.

queryString string
Contains the query string to be appended to the redirection url. Only applicable when type is set to redirect.

Checking Your Environment Details

Checking Your Environment Details

Accessing the System Status PageSending System ReportsUnderstanding the System Status PageGravity Forms EnvironmentGravity FormsAdd-OnsDatabaseWordPress EnvironmentWordPressActive ThemeActive PluginsServer EnvironmentWeb ServerPHPMySQL

As of Gravity Forms 2.2, it』s possible to see full details on your hosting environment from directly within Gravity Forms. Investigating your environment details is one of the first and most helpful steps when troubleshooting an issue.

Accessing the System Status Page

To access your environment details, simply access the System Status page. To do so, hover over Forms on the left side menu in your WordPress admin, and click on System Status.

If the System Status menu item is missing on your site there are two possibilities:

The site is running a version of Gravity Forms which is older than 2.2, please update to the latest version.Your user role does not have the gravityforms_system_status capability enabled. You can use a role management plugin such as Members to enable the plugin capabilities for roles.

Sending System Reports

System reports can easily be sent by simply clicking on the Copy System Report button at the top of the page. Upon clicking on it, a fully text-based copy of the report will be automatically sent to your clipboard and can be pasted anywhere. This is especially useful to send when submitting a support request.

If you find the system report does not copy to the clipboard you will want to run through a theme/plugin conflict test.

Understanding the System Status Page

Within the System Status page, there are several items listed and grouped together.

Gravity Forms Environment

This section contains various information that directly impacts Gravity Forms.

Gravity Forms

ItemDescriptionVersionThe version of Gravity Forms that is currently active.Upload folderThe absolute path to the folder that Gravity Forms will use for file uploads.Upload folder permissionsThe permissions that Gravity Forms has for your upload folder. It should display Writeable. If not, you may have issues with file upload fields.Output CSSIndicates if outputting of the form stylesheets is enabled or disabled.Output HTML5Indicates if the form fields should use the available HTML5 input types.No-Conflict ModeIndicates if extraneous scripts and styles are being prevented from inclusion on Gravity Forms admin pages, reducing conflicts with other plugins and themes.CurrencyThe currency code the forms are configured to use.Background updatesIndicates if Gravity Forms can download and install bug fixes and security updates automatically in the background.LocaleThe locale code being used by WordPress when loading the Gravity Forms translations.

Add-Ons

This section will list all Gravity Forms add-ons currently activated on your site, as well as the creator. Official add-ons will state the creator as Gravity Forms. 3rd party add-ons will show a different creator.

Database

Inside the Database section, information relating to Gravity Forms database tables will be listed. This includes the version number of the Gravity Forms database, as well as the status of the database tables used by Gravity Forms.

Within this section, you can also re-run the database upgrade. If you』re having database-related issues, especially after an update, re-running the database upgrade can often solve them.

WordPress Environment

This section contains various details about your WordPress installation.

WordPress

This section includes general information about your WordPress installation.

ItemDescriptionHome URL and Site URLThe URLs assigned to your WordPress site. Typically, unless you have a specific reason otherwise, these should be the same.WordPress VersionThe version of WordPress that you are running.WordPress MultisiteIf this is a multisite installation, it will appear here.WordPress Memory LimitIn addition to your memory limit within your PHP configuration, WordPress also sets its own memory limits. The WordPress Memory Limit list item will display the currently set memory limit, as defined within WordPress.WordPress Debug Mode, WordPress Debug Log, and WordPress Script Debug ModeIf debugging is enabled on the site using the WP_DEBUG constant, the mode will be displayed, as well as the log may be enabled. If WP_DEBUG is not turned on, they will both display No.WordPress CronIndicates if the cron is enabled or has been disabled using the DISABLE_WP_CRON constant.WordPress Alternate CronIndicates if the alternative, redirect based cron, has been enabled using the ALTERNATE_WP_CRON constant.Background tasksIndicates if your site is able to send a post request to it』s Admin Ajax URL using the WordPress HTTP API to trigger processing of queued tasks. If there is an issue an error message or status code from the test request response will be displayed.

Active Theme

The active theme section will provide information regarding the active theme and it』s parent theme (if applicable).

Active Plugins

The active plugins section will provide information regarding what plugins are installed and activated on your site, along with the version number.

Server Environment

These status items display information related to your server and hosting environment. Often times, you will need to contact your web host if there are any issues here.

Web Server

The Web Server section displays information about the software that serves your pages, typically Apache or NGINX. It also includes the document root that the site is being displayed and the port that it is running on (usually ports 80 or 443).

PHP

Inside the PHP section, you』ll see information related to PHP options that may impact your site. The most notable of these is Version, which should be as high as possible (PHP 7.1 or newer is recommended).

We won』t go over all of the items displayed here, but more details related to PHP configurations can be found on the PHP documentation site.

MySQL

Lastly, details on the MySQL database are displayed, such as the version, character set, and collation.

Configuring a Feed for the PayPal Checkout Add-On

Configuring a Feed for the PayPal Checkout Add-On

SummaryConfigure a feedFeed Settings ReferenceProducts and Services SettingsPayment AmountOther SettingsBilling InformationOptionsConditional Logic

Summary
The feed configuration determines what type of transaction should occur when the form is submitted, what to use as the payment amount, and which fields contain values that should be passed to PayPal.
If you have have added a PayPal Field to your form, you should find that a feed has already been created and configured automatically for you in the Form Settings > PayPal Checkout area. You』ll want to view this feed to ensure the Billing Information fields are mapped to the correct form fields.
Configure a feed

To configure a PayPal Checkout Feed do the following from your WordPress Admin Dashboard:

Click on Forms in the left side menu.
Select the form that you want to use with PayPal Checkout.
Once within your desired form, hover over Settings and click on PayPal Checkout.
Click Add New to create a new feed or click the Edit action link which appears when you hover over an existing feed in the table. You will then be presented with the PayPal Checkout feed settings screen.

Note: You can create multiple PayPal Checkout feeds for your form; however, you must configure conditional logic on them. The PayPal Checkout Add-On will only process one feed during submission; if conditional logic is not configured, it will use the first feed it finds.
Feed Settings Reference

The following fields are available within the settings screen.

A feed Name is required. It is only used for identification and will not be shown anywhere other than your feed listing.
Select the Transaction Type. This drop down contains the transaction types which the add-on supports. Products and Services or Subscriptions (recurring payments).

Products and Services Settings
If you select Products and Services from the Transaction Type drop down, the options below will appear.
Payment Amount

This drop down allows you to select what should be used as the payment amount. A specific product field within your form or the form total.
Other Settings
Under the Other Settings section, there are several other fields that can be configured.
Billing Information

Configures what billing information is sent to PayPal when processing a transaction. Map each of the billing fields to the desired form field that will contain that information.
Options

If you do not need PayPal to capture a shipping address, enable the checkbox labeled Do not prompt buyer to include a shipping address.
Conditional Logic

If unchecked, every successful form submission will be sent to PayPal. If you want payment to be conditional based on how the user completes the form, check the 「Enable Condition」 box and fill out the rules which must be met.

Changing the Payment Description in the Stripe Add-On

Changing the Payment Description in the Stripe Add-On

If you need to change the payment description that is sent from your form to Stripe, you can do so quite easily using the gform_stripe_charge_description filter.
To do so you will need to place a bit of code within your site, such as your theme』s functions.php file or ideally, within it』s own plugin.
1234add_filter( 'gform_stripe_charge_description', 'change_stripe_description', 10, 3 );function change_stripe_description( $description, $strings, $entry ) {    return $description . '  Purchased By: ' . rgar( $entry, '1.5' );}
As you can see in the above example, the filter is being called which contains the order description, and form information. From here, we are modifying that information to contain not only the original description which is set to the $description variable, but also defining who the order was purchased by based on a field submission value.
For more information on the gform_stripe_charge_description filter, take a look at the main gform_stripe_charge_description article.

Nested Conditional Logic Limitations

Nested Conditional Logic Limitations

DisclaimerWhen will nested conditional logic work?When will nested conditional logic not work?WorkaroundsBulletproof MethodDrop Down PlaceholdersFinding nested conditional Logic

Disclaimer

Gravity Forms does not officially support nested conditional logic. This means a field should not have conditional logic based on a field that also has conditional logic. Some clever folks have come up with workarounds or specific scenarios they feel work, but these are not officially supported by us.

With that in mind, here is some info that may or may not be of use!

When will nested conditional logic work?

Nested conditional logic will work if the conditional field does not have a default value, is not dynamically populated, and, if the field is a Drop Down, it uses a placeholder.

When will nested conditional logic not work?

Nested conditional logic will not work if:– the conditional field has a default value– the conditional field is dynamically populated– if the conditional field is a Drop Down and does not use a placeholder.

When Gravity Forms hides a field via conditional logic, it resets the field』s initial value. Conditional logic dependent on this field will be evaluated with that reset value rather than an empty value which is unexpected.

Workarounds

Bulletproof Method

The best method to support nested conditional logic is to add additional conditions to account for the nested dependency.

For example:

Field B is conditionally dependent upon Field Ayou want Field C to be conditionally dependent upon Field B

In this case, you would set up Field C』s dependence on B, but also add the conditions that you configured for Field B onto Field C as well. In this was you make Field C explicitly dependent on both Field B and Field A.

Conditional logic as configured for Field B

Conditional logic as configured for field C, in order to enforce the nested dependency.

Drop Down Placeholders

Nested conditional logic issues are most commonly exposed by Drop Downs. If the Drop Down does not have a choice with an empty value (such as a placeholder), the Drop Down』s value will be reset to that of the Drop Down』s first option when the field is hidden via conditional logic. Since the field is hidden, many users expect the value of the field to be empty and create nested conditional logic rules based on this assumption.

The simplest solution is to make sure your Drop Down has a placeholder. In this way, the Drop Down value will be reset to an empty value (via the placeholder) when hidden via conditional logic. Note: This does not address the issues with setting a default value and dynamic population mentioned above.

Finding nested conditional Logic

To check if your form has any nested conditional logic, copy and paste this script into your browser』s console on the form editor page.

123456789101112131415161718192021222324252627282930var deps = {}; for( var i = 0; i < form.fields.length; i++ ) {   var field = form.fields[i];  if( ! field.conditionalLogic ) { continue; }   if( typeof deps[ field.id ] === 'undefined' ) { deps[ field.id ] = []; }   for( var j = 0; j < field.conditionalLogic.rules.length; j++ ) {    var rule = field.conditionalLogic.rules[j];    if( jQuery.inArray( rule.fieldId, deps[ field.id ] ) === -1 ) {      deps[ field.id ].push( rule.fieldId );    }  } } for( var fieldId in deps ) {   if( ! deps.hasOwnProperty( fieldId ) ) { continue; }   for( i = 0; i < deps[ fieldId ].length; i++ ) {    var depFieldId = deps[ fieldId ][i]; // Does current dependent field have any dependencies?    if( typeof deps[ depFieldId ] !== 'undefined' ) {      console.log( 'Nested dependency found', '|', 'ID:', fieldId, '|', 'Label:', GetFieldById( fieldId ).label );    }  } } It will output a message for each dependency found. Nested dependency found | ID: 3 | Label: Field C

How to Change the Gravity Forms License on a Site

How to Change the Gravity Forms License on a Site

SummaryPre-RequisitesUpdating the KeyNotes

Summary

There is a chance you may need to replace the Gravity Forms license key in use on one of your websites with a different Gravity Forms license key.

For example, your license may have expired and you have purchased a new one, or you can no longer contact the developer who originally set-up your website and you want to replace their Gravity Forms license key with one you can control and manage yourself.

Pre-Requisites

Administrator access to a WordPress website that has an existing Gravity Forms license key installed and registered on it.A new Gravity Forms license key. See this article for information on how to find your key within your Gravity Forms account. You can purchase from the Gravity Forms pricing page.

Updating the Key

It really is as easy as pasting the new key over the hold one (though note that the old one is a hidden field, and represented only by asterisks).

Simply:

Navigate to Forms > Settings.Under General Settings, paste your new license key into the Support License Key field.Click the Save Settings button at the bottom of the page.A green check mark should be displayed next to the field if your license key has been successfully activated.

Image: A successfully validated Gravity Forms license key

Notes

Make sure the new license key has the same capabilities as the installed license you are replacing (or exceeds them). Otherwise you may lose access to needed add-on updates, have an insufficient site allowance, or lose your Priority Support status. See this article for a summary of license types and their benefits.Changing your license key does not disrupt any of your form functionality, and will not cause the loss of any existing form data. You can make this change without disruption. If your key does not validate, check this table for a list of possible validation errors you may encounter.

Using Confirmation Query Strings to Populate a Form Based on Another Submission

Using Confirmation Query Strings to Populate a Form Based on Another Submission

The ChallengeHow To SolveQuick SummarySetting up the first form to send data using confirmationsSetting up the second form to receive the submitted data

The Challenge

You have two forms. The first form is used to capture general customer information, and the second is used to create a new user account on your site. Instead of creating an account with the first form using the user registration add-on, you would rather only register the user with the second form (maybe that form is used directly ions one circumstances, or the first form only creates the account under certain conditional logic criteria). In such a scenario, it is unfriendly to ask the customer to enter their information twice.

This tutorial covers a method to pass data submitted from the first form over as default values in the second.

How To Solve

The method described here uses query strings passed in the confirmation redirect, which allow you to pre-populate the second form based on the first form』s submission.

In this article, we will show you how to configure your forms and the confirmation such that data from the first form can automatically populate fields on the second form.

Want a simpler (third party) solution? For an alternative solution that is easier to setup and keeps your URL strings nice and clean, check out the third party plug-in Easy Passthrough from the folks at GravityWiz. They have a detailed 「how to」 article as well.

Quick Summary

For those that just need a quick summary, these steps may be enough. If not, review the detailed screens below.

In the first form:

Modify a confirmation of the first form to have Confirmation Type: Redirect.Enter the Redirect URL as the web page address of the second form. In the Pass Field Data via Query String field enter the query strings you wish to pass in a parameter_name=field_merge_tag format.

In the second form:

Select a field you want to receive from the first form. Check the box for 「Allow field to be populated dynamically」. Enter the query string you passed into the Parameter Name box for that field. Repeat for all passed fields.

Setting up the first form to send data using confirmations

To begin reading data from the first form, it must output the data in some way to allow the second form in the process to read from it. This is where confirmation query strings come into play. In this section, we will show you how to set up confirmation query strings to be passed from the first form to the second.

First, you will need to access your first form that will be entered by the user. In this example, we will be using a general customer information form. We will be including a Name, Email, Address, Website, and Phone field.

Next, hover over Form Settings and click on Confirmations. Select an existing confirmation, or add a new one. Most users would simply edit the default confirmation.

Once here, select the Redirect option for the Confirmation Type. This is because instead of simply displaying a confirmation message, we need to redirect data to the secondary form.

In the Redirect URL field, enter the URL of your secondary form. If you have not already created a second form, go ahead and do so as well as embed it within a page and obtain the URL for that page.The Pass Field Data via Query String field will be formatted such a way that you will have a variable containing a variable. The contents of these variables will be populated using merge tags. For example, it will look something like this: first_name={Name (First):1.3}&last_name={Name (Last):1.6} In the example above, we are creating variables for first_name and last_name, and assigning them to the corresponding submitted fields using merge tags. As we have multiple variables here, they are separated with an & symbol. To review and insert available merge tags, click the merge tag icon to the right of the field.Once all of your fields are configured to send the appropriate query strings to your secondary form, save your settings and continue on to the next steps to set up the second form that will receive the submitted data from the first.

Setting up the second form to receive the submitted data

Now that your first form is configured properly to send the submitted data via a query string, you will now need to set up the second form the receive that data and automatically populate fields from it.

Begin by accessing the second form that will receive data from the first.

Once you have done so, select a field that you would like to be automatically populated. In the screenshot below, we would like the Name field to be automatically populated.

From within your selected field, click on the Advanced tab and select the checkbox labeled Allow field to be populated dynamically. This will allow the field to become populated based on the data sent to it.

Now that dynamic population has been enabled for this field, you will simply need to map the query string variables that are sent in the first form, to be accepted and used in the second form. In the prior example that we used, the First Name field was set to the first_name query string variable. To allow the second form to accept and use this query string, simply enter first_name into the box labeled First, under Parameter Name. Of course, the exact information you will enter here will vary based on the query strings that you have created earlier.

That』s all there is to it. Any fields you configure this way will now become automatically populated based on the content you have configured them to receive from the initial form submission.

You should now have a solid understanding of how to dynamically populate a form based on another form』s submission.

Setting Up the CleverReach Add-On

Setting Up the CleverReach Add-On

Pre-RequisitesSetupAdd-On Framework Hooks

Pre-Requisites

Download and install the add-on
A CleverReach account
The PHP extension PHP Soap must also be present on your web server. Most web hosts will already have this PHP extension installed and enabled.

Setup

Log into your WordPress admin dashboard.
On the left side navigation menu, hover over Forms and click on Settings.
From this page, click the CleverReach tab.
Enter your Customer ID, Username, and Password. This is obtained from CleverReach.
Click Update Settings. If you』ve entered your account information correctly, you will be notified by green check marks beside each box. If you do not see green check marks, please double check this information and try again.

Once you have entered your API key, you』re ready to begin creating a feed for the CleverReach Add-On.
Add-On Framework Hooks
Because the CleverReach Add-On is built using the Add-On Framework it also inherits any hooks available in the framework methods it uses such as:

gform_short_slug_field_value for changing a field value before it is passed to CleverReach.