Super Forms
  • Drag & Drop Form Builder for WordPress
  • Quick start
    • Installation
    • Registration
    • Starting your 15 day trial
    • Purchasing a license
    • Activating a license
    • First time setup
    • Secure file uploads
    • Creating a form
    • Adding form elements
    • Editing elements
    • Publishing your form
    • FAQ
  • Account
    • Dashboard
      • Your Invoices
      • Billing details
      • Your Licenses
      • E-mail Notification
      • Password reset
      • Cancel subscription
  • Common problems
    • Common problems
      • Email delivery problems
        • Why is my form not sending emails?
        • Why are emails going into spam folder/inbox?
      • File upload problems
      • Session expired
      • reCaptcha Troubleshooting – Fix “Not Loading” & Verification Errors
  • Elements
    • Layout elements
      • Column/Grid
      • Multi-part / step
    • Form elements
      • Calculator
      • Signature
      • File upload
      • Datepicker
      • Variable field
      • Dropdown
      • Text field
      • Autosuggest
      • Keywords
      • Radio button
      • Keyword Field
      • Button
      • Audio Recording (microphone)
    • HTML elements
      • Heading
      • HTML (raw)
      • Image
      • TinyMCE
      • Divider
      • Spacer
      • PDF page break
      • Google map element WordPress form
  • Features
    • Basic
      • Confirmations emails
      • Save Form Progression (continue later)
      • Build In Translation System
      • Populate form
      • Popups
      • Import & Export
      • Hide form after submitting
      • Hide or lock out user from your forms
      • Validation
    • Advanced
      • WordPress form with Google sheets dropdown
      • Custom registration form for WordPress
      • Custom login form for WordPress
      • Custom lost password form for WordPress
      • Update current logged in user
      • Secrets
      • Prevent duplicate entries
      • Lock & hide form
      • Password protect
      • Conditional Logic
      • Tags system
      • Address lookup/auto complete
      • Analytics Tracking
      • Conversion Tracking
      • Distance & Duration Calculation
      • If statements
      • Foreach loops
      • E-mail Reminders
      • Variable Fields
      • Form templates - Include elements into other forms - WordPress
      • Transferring data from one form to another
    • Integrations
      • PDF Generator
      • Listings
      • WooCommerce Checkout
        • Fixed price checkout
        • Dynamic price checkout
        • Variable product checkout (variations)
        • Replacing the "Add to cart" on a product page with a form
        • Hiding product from shop and order via custom form
      • PayPal
      • MailChimp
      • Mailster
      • Zapier
      • Stripe (BETA)
      • WooCommerce Instant Order (in progress)
  • Tutorials
    • WordPress Form to Google Sheet Integration
    • GDPR Consent / Terms agreement
    • How to update the plugin
    • Sending emails to specific department for WordPress contact forms
  • Example Forms for WordPress
    • Booking 24 hours ahead of time
  • Developers
    • Code Examples
      • Lookup City by Zipcode for your WordPress form
      • Audio Recording Field
      • Custom API Phone Number Validation for Your WordPress Form
      • Updating WordPress user meta data after login
      • Automatically redirecting to next step after displaying text or a progress bar
      • Dropdown with groups (categories)
      • Prevent form submission based on entered field values
      • Track form submissions with GTM (Google Tag Manager)
      • Tracking Multi-part steps with Google Analytics
      • Tracking Multi-part steps with GTM data layer (dataLayer.push)
      • Track form submissions with third party
      • Compare input field value with database value
      • Insert form data into a custom database table
      • Delete database row after contact entry is deleted in WordPress
      • Limited date availability (slots) for your WordPress booking form
      • Send submitted form data to another site
      • Exclude empty fields from emails
      • Execute custom JS when a column becomes conditionally visible
      • Toolset Plugin: Update comma separated string to Array for meta data saved via Front-end Posting
      • Toolset Plugin: Update file ID to file URL for meta data saved via Front-end Posting
      • Delete uploaded files after email has been send
      • Increase Cookie lifetime for client data such as [Form Progression]
      • Altering cookie secure and httponly parameters
      • Define fake cronjob to clear old client data if cronjob is disabled on your server
      • Define page language attribute based on page ID or URL
      • Define custom headers when doing a POST request
      • Change checkbox/radio layout to vertical on mobile devices
      • Show remaining available form submission allowed
      • Global fields / elements
      • Trim values of fields
      • Re-sending E-mails after editing entries via Listings for WordPress
      • Combine multiple field values into one column on Contact Entries page
      • Altering the attachments for E-mails via PHP code for WordPress
      • Generate dynamic columns with dates based on user selected date from Datepicker element
      • Hide `eye` icon from Listings row based on user role
    • Data storage
    • BETA version
  • Changelog
  • Support
Powered by GitBook
On this page
  • What is an email if statement?
  • Construction of "if statements" explained
  • How to create my own if statements?
  • Practical example use cases
  • Checking if a field exists
  1. Features
  2. Advanced

If statements

Displaying data/content conditionally inside your HTML element and or email body with the build in "if statements" for your WordPress forms

PreviousDistance & Duration CalculationNextForeach loops

Last updated 1 year ago

If statements can be used inside your and inside your . You can also combine it within .

What is an email if statement?

With the build in if statements feature you will have more flexibility as to how your email body and or HTML element is generated based on user input in your WordPress form.

In short it allows you to (just like any programming language) construct your own if statements inside your HTML element and or email body content.

Construction of "if statements" explained

Each if statement has a so called operator to do a so called "Comparison Operation". Inside our WordPress forms (and email body content) we can use one of the following operators for our statements:

  • == (equal to)

  • != (not equal)

  • > (greater than)

  • < (less than)

  • >= (greater than or equal to)

  • <= (less than or equal to)

  • ?? (contains)

  • !?? (does not contains)

How to create my own if statements?

A basic example of this would be to compare a field value with a hardcoded value, for instance if you want to display some additional information only to users who are named John we could do the following:

if({first_name}=='John'):
    Your custom HTML here...
endif;

When you require to output a default text whenever first_name is not equal to John we can use the elseif statement as shown below:

if({first_name}=='John'):
    This text is only for John :)
elseif:
    This text is for everyone who isn't named John
endif;

Practical example use cases

Below we will cover some practical use cases that you can apply to your own application(s).

Use case 1: Show extra information based on a selected package:

A simple use case would be to add some text that is specific for a package that a user selected inside your WordPress form. Let's say the package name is called package_1 and it's value when chosen by the user is daily_backups. When the user selected this package to be included in their order, we would want to display some important information regarding how these backups are being created by the company.

if({package_1}=='daily_backups'):
    Your backups are being stored daily on 3 other independent servers.
    By default your server has a fallback server that will be activated whenever the server is down for more than 2 min.
    If you need more technical information about how we process backups read our <a href="domain.com/faq">FAQ</a>
endif;

The above if statement will output the content depending on your own needs whenever the tag {package_1} is equal to daily_backups

Use case 2: Ask for parental consent when underaged:

Another example could be to check if a user is underaged or not and display some information about needing a parental consent:

if({age}<18):
    Because you are underaged we need a parental consent.
    Your parent(s) or guardian(s) need to sign the attached PDF file and return it by replying directly to this email address.
    They can also send it to the following post address: ...
endif;

The above if statement will display the message only when the user is underaged

Checking if a field exists

In these cases you might want to check if a field exists (is set). You can do so by using the isset() method. For example:

if(!isset(company_name)):
    The field named `company_name` does not exists, this registration is not a business registration.
endif;

if(isset(tax_id)):
    The Tax field was conditionally shown, this is a business registration.
elseif:
    This is a regular customer registration.
endif;

Inside our (delivered to the user who filled out the WordPress form) we can enter the following if statement:

When you are using in your form, in some cases a field might not be set due to it being conditionally hidden.

HTML element
email body content
foreach loops
Confirmation email body
conditional logic