DEV Community

GretaThemes
GretaThemes

Posted on • Edited on • Originally published at gretathemes.com

How to Add Contact Forms Using Plugin - P2: Use WPForms

In the previous article of the "How to Add Contact Forms Using Plugin" series, we've learned what a contact form is and how to use Contact Form 7 plugin. As promised, I wrote another tutorial with WPForms and I'm going to show you in this article.

WPForms is a freemium drag-and-drop contact form plugin with a real-time preview. In my experience, it's easy and convenient to work with this plugin.

Do you remember this university registration form sample that we've created in part 1 of this series? Now, we're going to create the same one with WPForms.

Create a university registration contact form with WPForms plugin

Step 1: Install and Activate WPForms Plugin

This plugin has a free version on wordpress.org, so you just need to install and activate the plugin right on the Admin Dashboard.

Step 2: Create a New Contact Form and Choose a Template

On your Admin Dashboard, go to WPForms > Add New.

Create a New Contact Form with WPForms plugin

Here is the interface that you have to work with:

The contact form interface of WPForms plugin

In the left sidebar, you can see 5 sections:

     
  1. Setup: Name the contact form and choose its template.
  2.  
  3. Fields: Add and customize fields for the contact form.
  4.  
  5. Settings: Configure the notifications, confirmations, and general settings.
  6.  
  7. Marketing: Link with email marketing tools such as Constant Contact, Campaign Monitor, Mailchimp, ...
  8.  
  9. Payments: Add payment from PayPal Standard, Stripe, and Authorize.Net.

Note: I don't run any email marketing campaign and my form doesn't require payment information. Therefore, I don't need the Marketing and Payments sections.

In the Setup section, enter your form name and select your desired template.

Select the desired template for your contact form.

There are four default templates:

     
  • Simple Contact Form
  •  
  • Newsletter Signup Form
  •  
  • Suggestion For
  •  
  • Blank Form

Excluding Blank Form, other templates have their own pre-built fields that you can utilize to build contact forms faster. In addition, you can install WPForms addons (only available on paid versions) to get more templates.

In this article, I choose the Blank Form template to build a contact form step by step from the beginning. This will help you understand everything more easily and deeply.

Create a university registration contact form with a blank form

Step 3: Add Fields for the Contact Form

Add Fields

After choosing the Blank Form template in step 2, you'll be moved to the Fields section.

The fields section of WPForms plugin

To add fields for your contact form, drag the desired fields from the Add Fields tab and drop them into the contact form.

Drag and drop the fields to the contact form

Next, to customize a field, click it, and then edit its parameters in the Fields Options tab.

Customize fields of the university registration form with WPForms plugin

Besides, you can delete or duplicate a field by hovering over it and click the desired buttons.

Duplicate and remove fields in the contact form with WPForms plugin

In this article, I need to add the following fields:

Field name Field type
Your Name Single Line Text
Your Phone Number Numbers
Your Email Email
Location to Study Dropdown
Major Dropdown
Register to Checkboxes

After adding all these fields, you need to customize each field in the next steps.

Customize General Options for Each Field

In general, there are two kinds of option to customize each field:

Basic options: all fields contain these options and you should absolutely work with them to make your contact form clear and understandable.

     
  • Label: Enter the field name that you want to display.
  •  
  • Description: This is the text display below the field to tell users what to do.
  •  
  • Required: It's optional! Tick it to make this field compulsory to be filled.

In the next steps, when I mention "basic information", it means you need to deal with these basic options.

Advanced options: there are some advanced features for each field. It's optional for you to deal with them, but there are some important things you should look at:

     
  • Placeholder text: Display a text inside the fields before users enter data. This text can be used as a guide or example to help users easily understand what they need to fill in. For example, you can set the Placeholder text of the email field as "Enter your email".
  •  
  • Default value: If there're many people who have the same answer, you can set a default answer to save time and effort of users. For example, you make a contact form for people who live in New York, so you can enter a default value of "New York" in the "Location" field.
  •  
  • CSS Classes: Enter CSS classes in this box to style the field. In the next step, I will include code in this section to style the contact form.

Note:

     
  • In Contact Form 7, you can use the default value as the placeholder text. But it's more convenient in WPForms because you have the separated Placeholder Text section. Besides, WPForms has the Description section that displays the text under the field. I use this way because it makes my contact form look better.

WPForms has the Description section that displays the text under the field.

     
  • You can click the question mark button beside the options / fields to read the instruction of WPForms for them.

click the question mark button to read the instruction of WPForms

Additionally, there are some different options depending on each field. Let's find out what they are!

Customize "Your Name" Field

Select the Simple Line Text field and just fill in the basic information:

Customize

In this field, there are 2 more options in the Advanced Options section:

     
  • Limit length: Check it to choose a limit for the maximum of characters that can be entered in the field.
  •  
  • Input Mask: Enter input masks to require specific formats for the field. Read more details here.

Advanced Options of the single line text field

Customize "Your Phone Number" Field

This field has nothing special. Just select the Numbers field and fill in the basic information:

Customize

Customize "Your Email" Field

Select the Email field and fill in the basic information for the field:

Customize

This field has one more basic option: Enable Email Confirmation. You can check it to ask users to provide their email address twice. This makes sure that their email is correct.

Customize "Location to Study" and "Major" Fields

First, choose the Dropdown field. In the Choices section, enter the options for the field. You can click (+) (-) to add / remove choices.

Customize

In addition, you can also click the Bulk Add button to add many choices at once. In the Add Choices box, fill in the choices in the desired order (each choice is a line) and then click Add New Choices.

Add choices to the drop-down menu of the contact form

In addition, in this field, there are 2 advanced options that you should care about:

     
  • Style: You can style your drop-down menu with two options: classic and modern. The modern style allows you to search by keywords. Therefore, it works well on menus with a lot of options (more than 10 options).
  •  
  • Dynamic Choices: Allow users to select choices from post types or taxonomies. For example, if you choose Dynamic Post Type Source as Posts, each choice in the drop-down menu is a post on your website.

advanced options of the drop-down field

Customize "Register to" Field

Select the Checkboxes fields and enter choices like the Dropdown fields.

Customize

In this field, there are 2 advanced options that you should care about:

     
  • Use image choices: You can use it to illustrate your choices and make your contact form more attractive and visualized.
  •  
  • Random Choices: This can avoid people from choosing a choice only because it's the first one.

Step 4: Configure the Contact Form

After creating a contact form, we need to configure it. In the free version of WPForms, you can configure three sections below:

Configure General Settings

WPForms plugin has specific instructions for each option in this part. You should click the question mark button, read it carefully, and pay attention to these fields:

     
  • Submit Button Text: In Contact Form 7, you have to create the Submit field. But in WPForms, the submit button is built-in. You can change the text of this button in this section to whatever you want, such as Register to, Send Email, ...
  •  
  • Enable anti-spam protection: Sometimes spammers may bother you through tons of "trash form". In that case, you should turn on this feature of anti-spam.

Configure General Settings of WPForms

Configure the Notifications

If you want to receive an email notification whenever a user submits a contact form, move to Settings > Notifications.

You can add "smart tags" or text to the fields in this section to manage the email you receive when a user submits a contact form more easily.

Note: Smart tags can add information to your contact form notifications automatically.

This is an example of my settings:

Configure the Notifications of WPForms plugin

Configure the Confirmations

In the Confirmation section, you can configure the messages that users receive after they submit contact forms.

Configure the Confirmations of WPForms plugin

When you finish all the configuration, just click Save.

Save the settings of WPForms

Step 5: Display the Form on Pages / Posts

To display your forms on pages / posts, there are 2 ways.

The first way is clicking Embed to display your form on a page:

Display the university registration form on pages / posts of your WordPress website

After that, embed the contact form in a new page or an existing page on your site.

Embed contact form in a page of your WordPress website

The second way is inserting the shortcode of the contact form to pages / posts. I recommend that you should choose the second way because it can display the contact form both on posts and pages. To do it, on the Admin Dashboard, go to WPForms > All Forms, find your contact form, and copy its shortcode.

Copy the shortcode of the university registration form

Next, paste this shortcode to the desired posts / pages.

Paste the shortcode in a post of your WordPress website

And here is the result:

The university registration form

It doesn't look like the contact form sample yet, so I have to style it a bit.

Step 6: Style the Form

On the Admin Dashboard, head to WPForms > All Forms, find your contact form and then click Edit.

Style the contact form

Now, click each field, go to Advanced Options > CSS Classes, and add the following values:

     
  • Your Name and Register to: ip-100
  •  
  • Your Phone Number, Email, Location to Study, Major: ip-50

Next, go to Customizer > Addition CSS, add this code:

.wpforms-field-container {

    display: flex;

    flex-wrap: wrap;

justify-content: space-between

}

.ip-50 {

    width: 48%!important;

}

.ip-100{

width: 100%!important;

}

div.wpforms-container-full .wpforms-form input.wpforms-field-medium,

div.wpforms-container-full .wpforms-form select.wpforms-field-medium {

max-width: 100%;

}

.ip-100 ul {

display: flex;

justify-content: space-between;

}

div.wpforms-container-full {

    margin-bottom: 24px;

    background: #eeeeee;

    padding: 20px;

}

Finally, click Publish.

And here's the final result:

The contact form after styling

The contact form looks better now, isn't it? Well, we have just finished the last steps to have a completely similar form to my sample.

Last Words

In my experience, using the drag-and-drop interface like in WPForms is easier and faster than using Contact Form 7. Besides, it has the pre-built submit button and 2 more useful sections as Placeholder Text and Description. The live preview is also very convenient. It helps me to detect mistakes more easily when creating and customizing the form.

To learn how to use more contact form plugins, follow our upcoming article of this series! If you have any questions about WPForms or suggest any contact form plugin, feel free to leave it in the comment section.
 --- --- --- 

The publication at GretaThemes.

Top comments (0)