---
title: "How to Use Contact Form 7 to Create a WordPress Form"
description: "When you're on a company's website and decide that you want to contact them directly, you'll likely look for contact information and social media links. You'll usually find an email address, phone..."
url: https://www.inmotionhosting.com/support/edu/wordpress/how-to-use-contact-form-7-to-add-a-form/
date: 2019-06-25
modified: 2024-03-22
author: "InMotion Hosting Contributor"
categories: ["WordPress Tutorials"]
type: post
lang: en
---

# How to Use Contact Form 7 to Create a WordPress Form

When you're on a company's website and decide that you want to contact them directly, you'll likely look for contact information and [social media](https://www.inmotionhosting.com/support/edu/wordpress/plugins/wordpress-guide-to-social-media/) links. You'll usually find an email address, phone number, and/or contact form. Contact forms are a popular method for feedback and customer service requests for many reasons:

- Hide your contact email address from [web crawling robots](https://www.inmotionhosting.com/support/edu/wordpress/block-bad-bots/) that may later use it for business email compromise (BEC) and other phishing attacks.
- Force users to provide required information with a specific format and alphanumeric character limits. For example, ensure users provide you a phone number with an area and country code.
- Easily manage user contacts with integrated [customer relationship management (CRM)](https://www.inmotionhosting.com/blog/what-is-crm/) solutions.
- Secure email inquiries with CAPTCHA and other anti-spam methods to reduce social engineering attacks.

You can't do all of that by providing an email address on your website. Companies using WordPress and other content management systems (CMSs) can do this more easily with plugins or modules instead of developing a [basic PHP mail() contact form](https://www.inmotionhosting.com/support/email/using-the-php-mail-function-to-send-emails/).

[Contact Form 7](https://contactform7.com/) is one of many options for WordPress forms, but it is among the most popular. If you look at the [WordPress.org plugin page](https://wordpress.org/plugins/contact-form-7/), there are over 5 million active installations of the plugin. Contact Form 7's biggest advantage over [weForms](https://www.inmotionhosting.com/support/product-guides/weforms/), [WPForms](https://www.inmotionhosting.com/support/edu/wordpress/plugins/wpforms/), and others is the list of free customization and input validation options available to those willing to code it.

Below we'll cover:

- [Installing Contact Form 7](#install) wp:list /wp:list
  - [Dashboard](#dashboard)
  - [WP-CLI](#wpcli)
  - [Manually](#manual)
- [How to Create a Form using Contact Form 7](#create)
- [Adding Contact Form 7](#add)
- [Redirecting Users](#redirect)
- [Securing Contact Form 7 forms](#secure) wp:list /wp:list
  - [Data input validation](#input)
  - [reCAPTCHA](#captcha)
  - [Same domain email](#same)
  - [Reply-to](#reply)
  - [Comment moderation](#comment)
  - [Email authentication](#email)

## Installing the Contact Form 7 Plugin

### Install from the Dashboard

1. [Log in to your WordPress dashboard](https://www.inmotionhosting.com/support/edu/wordpress/logging-into-wordpress-dashboard/).
2. [Install the Contact Form 7 plugin](https://www.inmotionhosting.com/support/edu/wordpress/plugins/install-wordpress-plugins/) and activate it.
3. On the left, select **Contact** to manage contact forms and integrations.

### Install via WP-CLI

1. [Log into SSH](https://www.inmotionhosting.com/support/server/ssh/do-you-provide-ssh-access/).
2. [Install and activate Contact Form 7](https://www.inmotionhosting.com/support/edu/wordpress/wp-cli/install-a-plugin-using-wp-cli/) using the following command: wp plugin install contact-form-7 --activate

### Install Manually

1. To install the plugin manually, download the plugin zip file from [WordPress.org/plugins](https://wordpress.org/plugins/contact-form-7/#installation).
2. [Upload the zip file](https://www.inmotionhosting.com/support/edu/cpanel/how-to-upload-a-file-using-file-manager-in-cpanel/) and [extract the folder](https://www.inmotionhosting.com/support/edu/cpanel/compressing-uncompressing-files/#uncompress) to the website’s `wp-content/plugins` folder.
3. Log into your WordPress site or use the WP-CLI command to activate the plugin:wp plugin activate contact-form-7

## How to Create a Form using Contact Form 7

1. In the WordPress administration dashboard, select **Contact** on the left. You'll be redirected to your list of contact forms.
2. You can click on the default contact form to edit it. Alternatively, you can click **Add New** at the top to create a new one. You can view [Contact Form 7 documentation](https://contactform7.com/editing-form-template/) to use the form.
3. Change the name at the top of the *Edit Contact Form* page to one you'll easily understand if listed among others in the contact forms list. This title isn't public facing.
4. Edit the form to meet your needs. To add a new form field, or form-tag, click where in the form you want to add the new field. Then, select the appropriate button (text, email, URL, etc.) and make changes as needed before selecting **Insert Tag**.
5. To add label text with a mail-tag, ensure you wrap them within a `<label>` tag.
6. **Save** changes at the bottom.
7. Select the **Mail** tab to configure how the email is sent.
8. Change the email address for the recipient of completed forms in the *To* field.
9. In the *From* field, set the sender address for submissions from this form. You can set it to use a dedicated sender email address to make [email filtering](https://www.inmotionhosting.com/support/email/setup-email-filters/) easier (e.g. `My Blog Contact Form <noreply@example.com>`) or the email address provided in the submitted form via the mail tag (e.g. ``).
10. Set the *Subject* field for contact form submissions. Similar to the *From* field, you can use a preset subject or dynamic subject that uses form-tags from the contact form.
11. You can add other email headers in the *Additional headers* section including CC, BCC, message-ID, content-type, organization, etc.
12. Edit the *Message body* to a format that allows you to easily intake the form submission. Ensure you use all mail-tags listed above the *To* field.
13. **Save** your changes. If a mail-tag listed above the *To* field is highlighted in bold, that means it is used in the form but not added in the Mail tab anywhere. Add it somewhere and save again before continuing.
14. Select the **Messages** tab.
15. Here, you can change the form notification for multiple situations including successful submission or when a field is filled in incorrectly.
16. **Save** changes once done.
17. Select the **Additional Settings** tab to [add other code](https://contactform7.com/additional-settings/) that affects how the contact form behaves such as redirecting to another page afterwards.
18. **Save** changes.

![Default Contact Form 7 form](https://www.inmotionhosting.com/support/wp-content/uploads/2020/10/contact-form-7-default-form-1024x680.png)

You can add the shortcode at the top of the page anywhere that will convert it correctly - posts, pages, [text widgets](https://www.inmotionhosting.com/support/edu/wordpress/313-use-shortcodes-within-text-widgit/), etc. The shortcode will resemble ``.

## How to Add a Contact Form

There are two main ways to add a contact form to your website:

- [Create or edit a post or page](https://www.inmotionhosting.com/support/edu/wordpress/create-edit-pages-posts-wordpress/) to add the Contact Form 7 shortcode to a shortcode block.
- [Install the Gutenberg plugin](https://www.inmotionhosting.com/support/edu/wordpress/gutenberg/add-gutenberg-block-functionality-wordpress-widget/) to add contact forms in text widgets.

![Contact Form 7 shortcode ](https://www.inmotionhosting.com/support/wp-content/uploads/2020/10/contact-form-7-shortcode.png)

## Redirect Users After Submission

One of the additional settings you can add to a contact form will redirect users to specific webpage after completing a contact form.

1. Edit a contact form.
2. Select the **Additional Settings** tab.
3. Type the following, replacing `yourdomain.com` with your preferred redirect URL: <script> document.addEventListener( 'wpcf7mailsent', function( event ) { location = 'https://yourdomain.com/'; }, false ); </script>
4. Press **Save**. The number beside *Additional Settings* matches the number of lines below.

![Redirect Users](https://www.inmotionhosting.com/support/wp-content/uploads/2019/06/contact-form-7-additional-settings-redirect-1024x546.png)

If the contact form doesn't redirect properly, you may need to troubleshoot what theme or plugin(s) are affecting your JavaScript settings. Otherwise, you can install [Redirection for Contact Form 7](https://wordpress.org/plugins/wpcf7-redirect/), by a different developer, which adds another tab for managing contact forms.

![Redirection for Contact Form 7 settings](https://www.inmotionhosting.com/support/wp-content/uploads/2020/10/redirection-for-contact-form-7-1024x465.png)

## How to Secure Contact Forms

As mentioned in our [PHP contact form](https://www.inmotionhosting.com/support/email/using-the-php-mail-function-to-send-emails/) article, contact forms with a plugin are usually a more secure option when using a CMS. To further benefit from that WordPress security, here are some ways to better secure form submissions with data validation.

### Data Input Validation

Text input fields should have character limits to prevent cross-site scripting (XSS) and similar cyber attacks:

- [Text sections](https://contactform7.com/text-fields) use maxlength:# – e.g. ``.
- [Number sections](https://contactform7.com/number-fields/) use max:# – e.g. ``.
- [File upload sections](https://contactform7.com/file-uploading-and-attachment/) use `limit:#mb`, `limit:#kb`, or `limit:#` (bytes) and restrict file types with filetypes:##|## – e.g. ``.
- Set anti-spam plugin [Akismet](https://contactform7.com/spam-filtering-with-akismet/) to scan fields for spam by selecting the **Akismet** checkbox in a form-tag generator.

### Use reCAPTCHA

Contact Form 7 officially supports [reCAPTCHA v3 for validation](https://contactform7.com/captcha/), not Really Simple CAPTCHA. Once you [register your website with reCAPTCHA](https://contactform7.com/recaptcha/), hover over *Contact* and select **Integration**. Then, under *reCAPTCHA*, select **Setup Integration**.

### Use the Same Domain in From Field

If the email account in the *From* field doesn’t match the website domain, email providers will see this and may mark it as spam. You can check this in the *Mail* section.

### Reply-To Address

You may want email conversations continued through an email account other than what’s specified in the *From* field. If so, change the `Reply-To` email in the *Additional Headers* section to another email account. Alternatively, you can add a CC line which may be preferable over creating an [email filter](https://www.inmotionhosting.com/support/email/setup-email-filters/) or [forwarder in cPanel](https://www.inmotionhosting.com/support/email/set-up-email-forwarder/).

### Comment Moderation

Along with using an [anti-spam plugin such as Akismet](https://www.inmotionhosting.com/support/edu/wordpress/plugins/top-anti-spam-plugins-for-wordpress/), you can edit the Comment Moderation section in the WordPress dashboard that Contact Form 7 will use to moderate sent email.

1. On the left, select **Discussion** under *Settings*.
2. Specify comments and IP addresses to block in the **Comment Moderation** text box.

![WordPress Comment Moderation](https://www.inmotionhosting.com/support/wp-content/uploads/2020/10/wordpress-comment-moderation-1024x199.png)

### Email Authentication

Enabling DKIM, SPF, DMARC, and PTR ensure your emails aren’t marked as spam. For more info on how to do this in cPanel, please see our [Block Spam Email in cPanel and Strengthen Email Authentication](https://www.inmotionhosting.com/support/email/strengthen-overall-email-authentication/) guide.

Also, consider using [WP Mail SMTP](https://www.inmotionhosting.com/support/edu/wordpress/plugins/wp-mail-smtp/) which is less likely to be marked as spam than the default PHP mail.

For more information on securing your WordPress website, check out [our recommended security plugins](https://www.inmotionhosting.com/support/edu/wordpress/plugins/recommended-security-plugins/) and [backup solutions](https://www.inmotionhosting.com/support/edu/wordpress/plugins/recommended-wordpress-backup-plugins/). You can also consider using the [Sucuri](https://sucuri.net/lp/promo/inmotion/?clickid=WWNTIZS7QxyLT9tQy%3ASR0UvEUkBWzkXLhTDQUQ0) web application firewall (WAF) for enhanced server security.

Learn how to make [accessible WordPress contact forms](https://www.inmotionhosting.com/support/edu/wordpress/plugins/accessible-wordpress-contact-forms/) or more possibilities in our [WordPress Education Channel](https://www.inmotionhosting.com/support/edu/wordpress/).
