Categories
Announcement WordPress Plugins

Contact Form 7 1.10

Contact Form 7 1.10 is now available. New features in this version include additional mail headers, response message placeholder tags [response], the calling of user-specified JavaScript code when a message is sent successfully, controlling JavaScript loading with new constant, and much more. Therefore, I would highly recommend that you upgrade today!

Download | Plugin Homepage | FAQ | Support Forum

(日本語のドキュメントは下のほうにあります。)

Additional Mail Header

In the past, Contact Form 7 allowed you to set mail headers of To, From and Subject. Have you ever thought of adding Cc or Bcc headers to your mail? The newly introduced Additional Headers fields in the Mail and Mail (2) section are just for that purpose.

You can input any header lines into the field; and you can insert any tags into any place in each header line, just like other Mail fields.

additional-headers

[response] Tag

After a reader of your blog submits the contact form, he or she sees a response message from Contact Form 7, such as “Your message was sent successfully” or “Validation errors occurred.” I sometimes hear from users who tell me that the position of the response message is not good, and, in fact, sometimes their visitors miss the message entirely.

In the past, the response message was shown at the bottom of the form. I changed this by allowing users to locate their response massage placeholder as they like. The response message is shown within the placeholder after submission.

A tag [response] for the placeholder has been introduced. You can insert this [response] tag into any place of your choice in your form. You can use it multiple times in a form. If there is no [response] used, the response message is shown at the bottom of the form by default.

JavaScript Action Hook: on_sent_ok

Sometimes you might think of running custom codes after the form has been submitted. For example, you may wish to run Google Analytics’s tracking code for tracking their visitor’s usage of the contact form and counting it as conversions.

The new JavaScript action hook would be useful in such a case. If you have a JavaScript code you wish to run after form submission is completed successfully, simply insert the code into the Additional Settings section (which is new in this version and is placed at the bottom of the admin panel) with preceding on_sent_ok keyword, like this:

on_sent_ok

Note that you need to quote the codes properly; and the code must be in one line.

To show you a more practical example, if you want to insert Google Analytics’s tracking function, enter it like this:

on_sent_ok: "pageTracker._trackPageview('/funnel_G1/step1.html');"

Controlling JavaScript Loading with WPCF7_LOAD_JS Constant

By default, Contact Form 7 loads three JavaScript files — contact-form-7.js, jquery.form.js and jquery.js — into each page. They are necessary for Ajax. I believe that the smooth form submission with Ajax is one of the better points of Contact Form 7; however, I’ve heard from users they don’t like this feature and think the loading of these JavaScripts is wasteful. So I have made it controllable.

When the value of WPCF7_LOAD_JS is set to false (default: true), Contact Form 7 does not load the JavaScript. You can set the value of this constant in your wp-config.php like this:

define ('WPCF7_LOAD_JS', false );

Tip: If you set WPCF7_LOAD_JS as false, but you wish to load the JavaScripts only on specific pages, call wpcf7_enqueue_scripts() in your template file. Note that wpcf7_enqueue_scripts() must be called before wp_head() is called.

Other Changes

  • Now you can specify the file upload limit size with kb and mb unit symbols. These three tags have the same meaning:

    [file your-file limit:1048576]
    [file your-file limit:1024kb]
    [file your-file limit:1mb]

    Note that you can’t use a decimal point in it (i.e., like this: [file your-file limit:1.5mb]) and it will be ignored if it exists.

  • A donation banner is displayed on the admin panel randomly. You might not see it as it is shown with very low probability.

    If you, or your client, hate to see anything about donations, you can stop displaying this banner by setting the value of WPCF7_SHOW_DONATION_LINK constant as false in your wp-config.php like this:

    define( 'WPCF7_SHOW_DONATION_LINK', false );

  • wpcf7_version(), wpcf7_read_capability() and wpcf7_read_write_capability() are removed. Use constants instead.
  • JavaScript is loaded in footer, instead of in a header, if it is allowed to do so. This has good performance merit.
  • Support of HTTPS is partly improved by using plugins_url().
  • An overall relocation and refactoring of codes and files has been done.

Translation Updates

New addition:

Updated:

Thank you.

Click here to lend your support to: Support Contact Form 7 and make a donation at www.pledgie.com !


(in Japanese from here)


Contact Form 7 1.10 をリリースしました。追加メールヘッダー、応答メッセージのプレースホルダーとしての [response] タグ、メッセージ送信に成功した時の JavaScript 呼び出し、定数での JavaScript ロードの抑制、などなど、たくさんの機能をこのバージョンでは導入しています。この機会にアップグレードをおすすめします。

追加メールヘッダー

従来の Contact Form 7 では To (宛先)、From (送信元)、Subject (件名) のメールヘッダを指定できました。これに CcBcc のヘッダーを追加したいと思ったことはありませんか? メールメール(2)両セクションに新しく導入した追加ヘッダー項目はまさにこのためのものです。

このフィールドに任意のメールヘッダー行を入力してください。それから、メールセクションのほかの項目と同様に、好きな場所にタグを挿入できます。

additional-headers

[response] タグ

ブログの訪問者がコンタクトフォームで送信すると、その訪問者は Contact Form 7 の応答メッセージを見ますよね。「あなたのメッセージを送信しました」とか「入力内容に不備があります」とか、そういうのです。よくユーザーから言われていたのですが、この応答メッセージを表示する場所がよくないので、訪問者がたびたびこのメッセージを見落としてしまうのだそうです。

従来のバージョンではこの応答メッセージをフォームの一番下に表示するようにしていたのですが、今回これを変更して、ユーザーが自由な位置に応答メッセージのプレースホルダーを置けるようにしました。応答メッセージは送信後にこのプレースホルダーの中に表示されるようになります。

このプレースホルダーを表現するタグとして、[response] を新たに導入しました。これをフォームセクションの中でならどこでも、何回でも挿入できます。もし [response] が1回も使われていなかったら、従来どおりフォームの一番下に応答メッセージを表示します。

JavaScript アクションフック: on_sent_ok

フォームの送信が完了した時に何かコードを実行したい、と思うこともあるかもしれません。例えば、Google Analytics のトラッキングコードを走らせて、訪問者のフォーム利用を追跡したり、それをコンバージョンとしてカウントしたりとか。

新しく導入した JavaScript アクションフックはそんなときに便利です。フォームの送信に成功した時に実行させたいコードがあったら、その先頭に on_sent_ok のキーワードをつけて、「その他の設定」セクション(これもこのバージョンで新規導入されたもので、管理パネルの一番下にあります)に挿入するだけです。こんな感じ:

on_sent_ok

コードを適切な引用符で囲む必要があるので気をつけてください。それからコードは1行に収まっていないといけません。

もっと実用的な例として、Google Analytics のトラッキング関数を使うならこんな感じになります:

on_sent_ok: "pageTracker._trackPageview('/funnel_G1/step1.html');"

WPCF7_LOAD_JS 定数による JavaScript ロードの抑制

デフォルトでは Contact Form 7 は contact-form-7.js、jquery.form.js、jquery.js の3個の JavaScript ファイルを個々のページでロードします。これは Ajax の機能に必要です。Ajax を使った滑らかな送信動作というのは Contact Form 7 の良いところのひとつだと自負していますが、聞くところによるとこの機能が好きではなく、このために JavaScript ファイルを読み込むのも無駄でしかないと考えている(いけすかない!)ユーザーもいるようです。仕方がないので、この機能をオン・オフ変更できるように変えました。

WPCF7_LOAD_JS 定数の値が false の場合(デフォルトでは true)、Contact Form 7 は JavaScript をロードしません。定数を設定するなら wp-config.php の中でこんな風にするといいでしょう:

define ( 'WPCF7_LOAD_JS', false );

裏技: WPCF7_LOAD_JSfalse に設定したものの、特定のページでは JavaScript を読み込ませたいという場合は wpcf7_enqueue_scripts() をテンプレートファイルの中で呼び出してください。wpcf7_enqueue_scripts()wp_head() より先に実行される必要があるので注意してください。

その他の変更

  • ファイルアップロードのサイズ上限指定に kbmb の単位シンボルが使えるようになります。次の3個のタグはどれも同じ意味になります。

    [file your-file limit:1048576]
    [file your-file limit:1024kb]
    [file your-file limit:1mb]

    小数点つきの値は使えないので注意してください。例えば [file your-file limit:1.5mb] のような指定をしても無視しますので。

  • 寄付呼びかけのバナーを管理画面に置かせてもらってます。ランダム表示でかなり低い確率でしか表示させないようになっているので、ひょっとしたら目にする機会はないかもしれませんが。

    もしあなたが(またはあなたの顧客が)寄付のことなど見るのも汚らわしいと感じているようでしたら、WPCF7_SHOW_DONATION_LINKfalse に指定して表示を解除してください。wp-config.php にこんな風に書くとよいでしょう:

    define( 'WPCF7_SHOW_DONATION_LINK', false );

  • wpcf7_version()wpcf7_read_capability()wpcf7_read_write_capability() の各関数を削除しました。もしこれらの関数を使っていたなら、今後は代わりに定数を使ってください。
  • JavaScript のロードをヘッダではなくフッタで行うようにしました(それが可能な場合のみ)。これによりパフォーマンスが多少よくなると思います。
  • plugins_url() を使用するようにしたことで HTTPS のサポートが多少改善されているはずです。
  • 全体的にファイル配置の見直しやコードのリファクタリングを行いました。

翻訳の更新

新規追加:

更新:

ありがとうございました。

Click here to lend your support to: Support Contact Form 7 and make a donation at www.pledgie.com !

70 replies on “Contact Form 7 1.10”

hi – and thanks for this awesome plugin!

question: can on_sent_ok: work with a conditional statement ? i’d like to be able to redirect depending on which of two radio buttons is chosen.

i’ve been experimenting, but so far no luck.

something like this :
on_sent_ok: “if (radiobutton==1st choice){
location.replace(‘mypage1.html’); }
else {
location.replace(‘mypage2.html’);” }”

help ??

hi – and thanks for this awesome plugin!

question: can on_sent_ok: work with a conditional statement ? i’d like to be able to redirect depending on which of two radio buttons is chosen.

i’ve been experimenting, but so far no luck.

something like this :
on_sent_ok: “if (radiobutton==1st choice){
location.replace(’mypage1.html’); }
else {
location.replace(’mypage2.html’);” }”

help ?

GoogleAnalyticsでのコンバージョン解析を行いたく、

on_sent_ok: “pageTracker._trackPageview(‘/funnel_G1/step1.html’);”

を、「その他の設定」に追加したところ、解析はうまくいったのですが、送信完了のメッセージがでなくなり、これはなんともならないでしょうか。

i’ve been trying to use the on_sent_ok hook and I still dont know if it is working in Google Analytics but the confirmation message is gone.

How can I fix that?

@jennyb, @medyum,

Maybe you could create a function that includes the conditional, say,

function foo () {
if (bar == 1) {
// do this
} else {
// do that
}
}

and then make the function call:

on_sent_ok:”foo();”

@Jussi

thanks – that’s definitely the gist of what i’m trying to accomplish! my problem, however, is retrieving the variables defined in my radio buttons so that the if/else knows what to do when.

when i get it figured out (and i will!), i’ll post it here.

cheers,
-jennyb

I have multiple forms and I want to redirect the user to a different page for each form.

However, this is not working. Everytime a user submits, he will be redirected to the page on the FIRST form.

Is there a solution to redirecting the users to the correct page when the submit button is pressed?

Hi ,

Thanks for this awesome plugin! I’ve installed this plugin and created many forms too. I need to call a php function after the mail has been sent in a particular form. By using the form_id can call the function. Pls anyone give an idea how to do this?

To utilize the latest Asyncronis Google Analytics API, use:

on_sent_ok: “_gaq.push([‘_trackPageview’, ‘/special/advertising/sent’])”

Also, what are the OTHER Javascript hooks?

Hi,

Thank you for this amazing plugin. Its helping me a lot! But i am stuck on one part. I am making a ‘complaint form’ and users at the moment can submit without any problem. What I want is that, the message post out as comment on blog? But I can’t seem to understand how to post the message as comment as well

Any help/advice?

Thanks

Leave a comment