WordPress Contact Us form – Redirecting Back to Previous Page

2017/07/14
By
Modified: 2017/06/25

How to implement a Contact Us form in WordPress?  This article describes how to add a very simple Contact from using WordPress 3.0.1 and two plug-in(s):

– Contact Form 7 and
– Really Simple CAPTCHA.

Later, you can customize the contact form to your delight using HTML tags through provided user interface.  Very flexible solution and as far as I can see – it is a bug free solution.

As you can see on the picture, this solution has a support for CAPTCHA image code.   CAPTCHA is an image with numbers and letters that appears above Submit button.  User is required to enter these numbers and letters into a text filed to ensure human presence and block the robots from sending automatic spam messages.

Under ideal circumstances you just need to upload, copy, and activate these two plug-in(s).   You do not need to do anything else. This is ready to use out-of the box solution.

If directory wpcf7_captcha is not created under your upload directory, you might need to give Write rights to your anonymous Internet user.  I’ve noticed that on Windows 7 and IIS 7.5 you need to add user IUSR to be able read and write to that directory (not the group IIS_IUSRS)  For some reason user IUSR is NOT a member of group IIS_IUSRS.

CAPTCHA requires something called GD and FreeType Support. Luckily, PHP Version 5.2.14 for Windows (http://php.iis.net/) comes with GD Support and FreeType Support.  You do not need to do anything additional – they are installed and configured for you to use. You can use your info.php to verify:

Out of the box contact form template doesn’t include CAPTCHA code on the form.   To add a CAPTCHA code and field, add this tag to your Contact Form 7 template:

[captchac your-captcha]
<label>Enter the code - Наберите Код <br />
     Case-insensitive - Используйте прописные буквы <br />
 [captchar your-captcha]</label>

You might notice a small problem with this solution. After sending the message, user still faces the same empty contact form.  There is a simple trick that doesn’t require changing the code.

I used template Message area to redirect to a previous page, if the message was sent successfully:

<script> window.location.href=”javascript:javascript:history.go(-1)”; </script>

This code (above) was tested and works on Windows based (IIS) server.

Here is a link, where I picked up this  super-great idea to insert a script into a success message box:

http://wordpress.org/support/topic/contact-form-7-redirect-to-a-thank-you-page

Next things to work on for this form are :
– How to pass parameters into the form to pre-populate Email To and Subject?
– How to limit the legth of input fields?
– Remove words “Comments are closed.” at the bottom of the page

Tags: , , , , , , ,


13 Responses to WordPress Contact Us form – Redirecting Back to Previous Page

  1. college board
    2011/04/23 at 11:53

    Having read this material, I have learned for myself a lot of the new. Thanks

  2. Mario Piting
    2011/03/25 at 15:40

    Having read this material, I have learned for myself a lot of the new. Thanks http://www.collegeboard.org/

  3. Zethosechoime
    2011/03/16 at 13:04

    Трябва да проверя:)

  4. super-hoster
    2011/03/03 at 09:49

    День добрый! Это информативный блог, сохранил в избранное. На каких условиях вы могли бы разместить здесь рекламную статью про блог о автомобилях?

  5. Registered nurse
    2010/12/04 at 18:57

    This is such a great resource that you are providing and you give it away for free. I enjoy seeing websites that understand the value of providing a prime resource for free. I truly loved reading your post. Thanks!

  6. Expedaappax
    2010/11/25 at 16:26

    Спасибо, полезный материал. Добавил ваш блог в закладки.

  7. Expedaappax
    2010/11/23 at 01:43

    В прошлом годы был на Ибице, так там познакомился с человеком, у которого стиль изложения материала очень похож на ваш. Но, к сожалению, тот человек очень далек от Интернета.

  8. Udar Gromov
    2010/10/26 at 11:35

    Ok! Good. Thank you! I was about to download and install Opera 10.63. I never even heard about them, but Opera and mini-Opera are about 25% of all my visitors.

  9. Parshivetz
    2010/10/26 at 11:15

    No problems for me viewing this site with Opera…

  10. aparadekto
    2010/10/25 at 23:26

    Hey, I can’t view your site properly within Opera, I actually hope you look into fixing this.

Add Your Comment Ваш Комментарий

Your email address will not be published. Required fields are marked *

* Ваше Имя *
* Ваш Email (не будет показан на сайте)*

*