There are a plenty of plugins that can be used for adding almost any functionality to your WordPress powered site. However, if you’re someone who like to build things from the ground up, then probably you won’t like to make use of the existing plugins. You can roll out your own stuff! When building something from scratch you’ll understand the underlying implementation of the thing that you’re creating, and will even gain skills that might end up using the same skills while working on another WP project.
Creating WordPress Contact Forms – A Foreword
Contact form is one of the most vital element of a site that serves as the communication point that your site visitors have with you. Unfortunately, not much focus is being paid during form creation. Let’s suppose you’ve a contact form that contains several stumbling blocks. Now in order to reach to you, your potential customers will have to wade through all those blocks. But the simple your contact form is, the lower will be the stumbling blocks for the customers.
However, building one with too many complex features can likely get your customer distracted when filling the form. Therefore, a sensible choice is to build a contact form from scratch without using a plugin, which includes only the essential fields such as name, email, message and verification code.
What’s more? People will get easily distracted while filling out the form and may even leave it in between. Remember, contact form plays a crucial role in improving conversion rate. However, lengthy forms will make users frustrate and they’ll most likely avoid using your services, as a result you will face constant decrease in conversion rate. Therefore, it becomes essential to cut short your contact form and include only relevant and required fields.
What’s Essential to be Added in Your Contact Form?
It’s pretty obvious that the we require details of our clients including name, email-id, and a short message. And not to forget human verification as well. Having these four key fields are most crucial and enough to get in touch with your clients. So, why make the contact form appear to be complex for the users. If you want you can even include contact number and location as additional fields in the form (but not unless they’re absolutely required).
Besides, interested people will always leave their contact details in the any section available in the contact form – such as the message box or any other section.
Why You Won’t Feel the Need to Install a Plugin?
So, now that you have decided to custom built a contact form but are confused on whether to use plugins or not to get the job done, then below are some of the basic reasons that will help you understand – why plugins can be a bad choice for creating simple contact forms:
- Plugins may embed functionality more than you actually need.
- Using a complex user interface to create a simple form and adding too much functionality is overkill.
- Building a plugin from the very beginning will help you gain knowledge about what’s under the hood, and you may use it while working on some other project.
- Often plugins contain faulty codes that can eventually result in bugs, which might either break your site or makes it run slowly.
That’s why you should create a WordPress Contact Form without Plugins.
Coding to Build a Plugin From Scratch
Step 1 – In order to get started with the custom plugin creation you can create a child theme of default WP theme, for example, I’m using TwentyTwelve along with a stylesheet and a custom page template. Just drop your custom theme into any one of the current themes.
Next, go to
wp-content/themes, and add a new folder named “my-new-contactform”. Within the form, build two new files namely
Now within the style.css file, add details like theme name (contact form page template), theme URI (http://contact.test.com/blog/), description, template and so on. After performing this step, you will be able to activate your own theme on your test site, as shown in the screenshot below:
Step 2 – Now create a page called “Contact Us” that relates to the template file that was created as above named contact-us.php, however, leaving the php file empty will generate a blank page. Just add the following mentioned code in the contact-us.php file:
Step 3 – Now just drop any simple form. And substitute the following in place of the text FORM CODE as mentioned above.
Now let’s understand the logic behind the above code. In the above code you can see we
echo $response variable and will use a function to get the response variable filled with the feedback post all the validation requirements meet up.
- Then there are just form tags, however the value of form tags echoes a $_POST variable. The purpose behind this variable is that if the form is submitted in a wrong manner, all the data is retained in order to spare the user from typing out everything gain from scratch.
- The code also contains a hidden form input that will let you know whether a customer has posted anything or not.
- Lastly, you can see an asterisk is placed subsequent to each input, in order to insinuate that those input are compulsory and should be filled by the users.
After saving the above code and refreshing the page, you’ll be able to view a simple and good-looking contact form!
Though there’s a lot more logic that goes into building a fully functional contact form for your WordPress site, however, through this post I’ve tried to explain the basic procedure that needs to be followed in form creation. Also, I’ve pointed out facts as to why using built-in WP plugins to integrate a contact form might not prove to be a good exercise.