ONW Simple Contact Form

ONW Simple Contact Form is a WordPress plugin which produces a very simple form which you can add to any page or post using a shortcode.  The form is not customizeable, although you can alter the appearance with CSS.

It has fully integrated reCAPTCHA, or a very primitive captcha-like bot check, asks for a name, email address, and body text, and then emails all of it to the blog’s administrative email address.

Once you’ve downloaded the .zip folder with the link on this page, install it into your ‘/wp-content/plugins/’ directory and activate it from the plugins menu of your dashboard.  Then, to insert the form into the desired page, simply click the ONW Simple Contact Form button in the pages/posts tinyMCE editor (the button looks like an opened envelope. Button introduced in v1.7). You may define overrides for recipient address and subject in the dialogue box that pops up, or you can use the defaults by leaving the popup box blank. This will insert the shortcode into the post at the cursor’s position. Alternatively, you can write the shortcode manually. It looks like this:

[onw_simple_contact_form subject=”%name% (%email%) sent an email your way” to_email=”email@example.com” onw_recaptcha=”on/off”]

in the editor (either visual or HTML mode).

Version 1.4.1 introduces full reCAPTCHA integration. To activate it, you need to go to reCAPTCHA.net and sign up for your free API keys, then put them into the appropriate fields on the settings page for ONW Simple Contact. Once the keys are entered, you need to enable reCAPTCHA on the same page. You can also opt to enable or disable the reCAPTCHA feature in each individual shortcode by setting the ‘onw_recaptcha’ argument to ‘on’ or ‘off’. In v1.5, I fixed a bug that would turn off all bot check functions if you put neither ‘on’ or ‘off’ in the shortcode argument. Now, if you don’t put in one of the two, it will revert to the global settings.

In version 1.6, I added the ability to customize the subject of the emails sent.  This can be done either on the admin screen or in the shortcode itself by using the `subject` argument.  To insert the user’s name or email address, use %name% or %email%.

in v1.7 I added a TinyMCE button to insert the shortcode automatically.

In version 1.8 I added a new tab to the admin page that allows admins to change the text above the form, remove or modify the fieldset and legend, and change the labels for the form’s fields.

A few additions and updates to come in the future:

  • Full reCaptcha integration Added in v1.4.1
  • User defined recipient (define the recipient email address with an attribute in the shortcode) Added in v1.2
  • An admin panel (Added in v1.4.1) for design and label modification (Added in v1.8)
  • I18n
  • WP-reCAPTCHA integration
  • … We’re open for suggestions.

50 Responses

  1. baron says:

    Works great, thank you

  2. NKL says:

    Do you mind posting a screenshot of how the contact form looks like not only how to use? Thanks.

  3. jay says:

    cool plugin

  4. John Bloch says:

    NKL:
    No problem. I just added them, and they should show up on wordpress.org/extend/plugins soon. I also added a section with instructions on how to use your CSS stylesheet to change the look if you want.

  5. Toni-Lynn says:

    I keep getting an error when I try to test it. Where do I set up where the email goes when someone sends??

    Thanks

  6. Toni-Lynn says:

    I found the post on how to designate the receipient but now I keep getting this
    Fatal error: Call to undefined function: filter_var() in /home/voteroya/public_html/wp-content/plugins/onw-simple-contact-form/onw_simple_contact.php on line 136

  7. John Bloch says:

    Toni-Lynn,
    What version of PHP and what version of WordPress are you using?

  8. Toni-Lynn says:

    WP 2.8.4 and what version of PHP?

    TY

  9. John Bloch says:

    Is the form displaying initially, or is the error appearing as you activate it?

  10. John Bloch says:

    Actually, now that I think about it, that doesn’t matter. From what I know of your problem, it’s either going to be a problem with the version of PHP your server is running or your php.ini file. filter_var is a standard php variable, and the only way it would be ‘undefined’ is if your hosting server is running a version of PHP older than PHP 5, or if the php.ini file has the filter_var function turned off.

    We should talk about this in more detail over email. You can use the form on my ‘contact us’ page to email me, and we’ll try to get this problem fixed from there.

  11. Toni-Lynn says:

    The form is displaying fine. Will email you :)

    Thanks

  12. Paul Borje says:

    Some changes…

    Row 47

    Cange from

    to

  13. Paul Borje says:

    Repeate

    Some changes…

    Row 47

    … scr=”/wp-content/…..

    to

    … scr=”./wp-content/…..

  14. John Bloch says:

    Shoot! Of course.
    Thanks Paul!

  15. veronique m. says:

    hello,
    i have teh same problem as toni-Lyan had…
    Fatal error: Call to undefined function: filter_var() in /usr/www/users/peau/disparates/delta/wp-content/plugins/onw-simple-contact-form/onw_simple_contact.php on line 136
    did you manage to solve the problem?
    thanks,
    veronique

  16. John Bloch says:

    Veronique,

    No, I haven’t solved that problem yet. I had been trying to work on a solution with Toni-Lynn, but nothing’s come of that yet.

    Since this seems to be a recurring problem, I’ll program a workaround for it in the next update.

  17. veronique m. says:

    thanks a lot !

  18. veronique m. says:

    Thanks !

  19. John Bloch says:

    I just released v1.3 which should solve the ‘filter_var’ problem that Toni-Lynn and Veronique have been having.

  20. Paul Borje says:

    1.4 uuuhuuu ERROR. Must deaktivate it…
    You must test it for \sub\ first…
    I think it works for root installations

  21. Paul Borje says:

    ERROR on line 34 in

    form/onw_simple_contact.php

    See it on (*LOL*) http://www.olympianetworks.com/projects/onw-simple-contact-form/

  22. John Bloch says:

    Yeah.
    I forgot to use ’svn add’ on the new recaptcha library file before I checked the new version in.
    Just added it. New version should work now.

  23. John Bloch says:

    New version works. You can see it in action here.

  24. Paul Borje says:

    Have a nice day…. ;-))

  25. John Bloch says:

    Bee,
    I’m not sure why it’s not sending it to your email. I tested it on your website and the page told me the email had sent, which means my plugin script is actually sending the email. You might check the settings and make sure you have the right email address specified.

  26. Dan says:

    would like to have the ability to alter or eliminate the descriptive text that shows prior to the form (“Please use the form below to send an email to the site administrator.”)
    Thanks
    Dan

  27. John Bloch says:

    Hi Dan,

    Thanks for the feedback.
    I was planning on adding the ability to modify the labels for the inputs and other ’stylistic’ things, anyway, and that seems like it would be a good time to take care of the top text too. I’ll add that to the to-do list.

    -John

  28. Dani says:

    I am getting the following error:

    Warning: mail() [function.mail]: SMTP server response: 451 See http://pobox.com/~djb/docs/smtplf.html. in D:\Hosting\5376430\html\wp-content\plugins\onw-simple-contact-form\onw_simple_contact.php on line 500

    I can’t find anything about it that makes sense.
    My domain is http://www.riseupfineart.com
    Thanks!

  29. John Bloch says:

    Dani,

    I think I know what the problem is, but I need some more information from you first. What OS is your site hosted on? Also, what is the email domain to which it’s sending/where are your mailservers located?

    Thanks,
    -John

  30. Dani says:

    Aloha John,
    The site is hosted on an unlimited server on my reseller account from goDaddy. I tried sending from a gmail account and then also kevin@riseupfinart.com because I thought maybe it had something to do with the gmail account. But I get the same result from both.
    Thanks!
    dani

    **thank you for your help, I intend on donating. I usually wait until I know I can get something working before I do. :)

  31. John Bloch says:

    Dani,

    Is it Windows or Linux hosting?

    It couldn’t have had anything to do with the sender’s address, since it’s sent by the script, not the actual email. The destination address would have more to do with it. Some msn emails will return an SMTP 451 error with raw LF’s (which is the problem). If it’s not the email, it’s probably the operating system. See if this works:

    From the plugins page, click ‘edit’ for ONW Simple Contact. Scroll to the bottom of the plugin file, and then start scrolling up until you see the line that says

    // And send it.

    Right above that it should say

    // Compile the email data,

    $mail_inputs = onw_compile_the_email($onw_form_inputs, $to_email, $subject);

    Immediately after that line (but before the ’send it’ comment) insert the following:

    $mail_inputs = preg_replace("#(?<!\r)\n#si", "\r\n", $mail_inputs);

    That should fix it, if the problem is what it looks like. If that doesn’t fix it, let me know (and please answer my earlier questions).

    So the finished product should look like

    // Compile the email data,

    $mail_inputs = onw_compile_the_email($onw_form_inputs, $to_email, $subject);
    $mail_inputs = preg_replace("#(?<!\r)\n#si", "\r\n", $mail_inputs);
    // And send it.
  32. Dani says:

    It is Windows. I will go and see if this works now. Thanks!!

  33. Dani says:

    YAY that worked!! Thank you so much. Just curious but what caused this and when I used this form again is there a way I can avoid it?

  34. John Bloch says:

    Awesome!

    Actually, It was my fault. In PHP mail, you technically can’t have any bare linefeeds (new lines), and have to have a carriage return before the linefeeds as padding. In the code, a ‘bare linefeed’ looks like

    \n

    whereas adding a carriage return looks like

    \r\n

    The message area that the form uses automatically inserts the linefeeds but not the carriage returns. So that was causing the SMTP 451 error. I’d never noticed that before because Linux doesn’t strictly require the carriage returns, but Windows does. Not having windows hosting, that error never occurred in testing.

    But this fix (which doesn’t alter Linux performance) will be in the next release.

  35. I’d like to install this as a contact form in a sidebar widget, so that a use clicks on it to ope. I don’t know how to do that. The plugin is installed and ready to go. But when I use the Tiny MCE editor, it doesn’t work. Can you tell me how, please?
    Thanks,
    ehtt

  36. RJ says:

    hi, cant get this to work on pages, only on post

    if I add the code to a page I just get the following text:- [contact-form]

    am using 2.9

  37. John Bloch says:

    RJ
    Are you sure the shortcode is correct? In the text editor it should say

    [onw_simple_contact_form]

    I’m not exactly sure why it would be replacing that with

    [contact-form]

    That seems to me that it would have more to do with WordPress’ shortcode functions than it would with my plugin.

    If you’re using the text editor button, try entering the shortcode by hand. If you’re entering the shortcode by hand, try using the tinyMCE button.

    What really perplexes me, though, is that it only works on posts

  38. Johnson says:

    simply displays like this

    onw_simple_contact_form to_email=”admin@mysiteid.com”

    that is the code of the site. I am using 2.9 version

    please help

  39. John Bloch says:

    Hi Johnson,

    Did you put the brackets around the code? in the text editor, it should look like

    [onw_simple_contact_form to_email=”admin@mysiteid.com”]

    If so, try inserting an image with a caption and let me know what happens.

  40. kylehase says:

    Why does this plugin use mail() and not wp_mail?

    Using wp_mail would make it compatible with other mail plugins such as the “configure smtp” plugin.

  41. John Bloch says:

    Two reasons it doesn’t use wp_mail: first, I built this plugin with a relatively low level of WP knowledge and have made improvements with time.

    Second, I haven’t finished looking through the functionality of wp_mail to see if it’s a necessary improvement. Remember, this is so other people can send email to you. Is SMTP really necessary if the ‘from’ address is an unknown? As I see it now, I really don’t see how this plugin would be improved by SMTP configuration (although I am open to enlightenment).

  42. Pankaj says:

    Is there any way to send email to more then one people..

    Thanks for the nice Plugin.

  43. John Bloch says:

    As of now, I don’t think there is a way to send it to more than one recipient. But that’s certainly something I could put into future versions.

  44. martin says:

    hi, could u integrate more languages?
    and please use the original re-captacha plugin, which is more customizable

  45. John Bloch says:

    I had actually been reading up on i18n in anticipation of adding other languages. You can expect to see that in one of the next two major releases.

    As for the reCAPTCHA plugin, it’s generally bad practice to make a plugin for public release that depends on a separate plugin for its functionality. In fact, I’ve never heard of a plugin that needed another plugin to work. What I can do some time in the future is add cross-compatibility so that you can use the wp-recaptcha plugin in my contact form, but that will be secondary to other concerns, since the plugin does already have functioning reCAPTCHA integration.

  46. Francis says:

    Hi John,

    Thanks for the great plugin!

    @ Martin

    Put the line

    echo “var RecaptchaOptions = {lang : ‘de’,};”;

    into the file own_simple_contact.php
    where “lang: xx” stands for the captcha’s language.

    as described here:
    http://recaptcha.net/apidocs/captcha/client.html

    I have put that in line 450, just at the beginning of the Form Functions Section and it works great.

  47. Francis says:

    in my post above several tags and backslashes have been stripped, so maybe John can contact me by email and repost the solution.

  48. John Bloch says:

    Hi Francis,
    Thanks for the input. I probably should have put this somewhere before, but putting code in backticks will escape special characters and use non-fancy quotes. So the following is escaped with backticks:

    <div><p>Text</p></div>

    I’ll see if the code is still there in your post. If not, please repost.

  49. John Bloch says:

    Here’s what Francis was talking about:

    To modify the way the recaptcha displays, go into the plugin editor. In the main file (it should be the default file you’re editing), go about two thirds of the way down the file to the Form Functions section. Find the second function called ‘onw_form_val_js’. You should see some code that looks like this:

    function onw_form_val_js($recaptcha) {

    // Prepare the javascript and assign it to a variable…

    $js_output = '<script language="Javascript" type="text/javascript">
    function onwFormValidate(){
    var nameField = document.getElementById("uName");
    var emailField = document.getElementById("uEmail");
    var messageField = document.getElementById("uMessage");
    var checkField = document.getElementById("uCheck");
    if(nameField.value==""){
    alert("Please enter your name.");
    nameField.focus();
    return;

    Right before the part that says 'function onwFormValidate(){', you can insert the following code to modify the way the recaptcha form looks:

    var RecaptchaOptions = { theme: "white" };

    The default theme is red, but you can change it to white, blackglass, or clean. You can also add support for other languages with:

    var RecaptchaOptions = { lang: "de" };

    That changes the language to German. Use the appropriate language code for your language. To use both theme customization and alternate languages, write the code with a comma between theme and lang:

    var RecaptchaOptions = { theme: "white", lang: "de" };

    I'll be working on integrating these settings in future releases of the plugin.

Leave a Reply