Categories
WordPress Plugins WordPress Tips

File uploading and attachment with Contact Form 7

In this post, I will explain the file uploading and attachment feature introduced in Contact Form 7 1.9. If you are not familiar with Contact Form 7, please read the plugin homepage and FAQ first.

Summary

With this feature, you can allow your visitors to upload their files via your form, and then an email with attachments of the files is sent to you.

Please note that this feature uses the API of WordPress 2.7. So, in order to use it, you will need to upgrade your WordPress if you are using WordPress 2.6.x or older.

To set up, two steps are needed: 1) Add file uploading fields in your form, 2) Set up your mail settings to attach the uploaded files. The two steps will be explained in the rest of this post.

Adding file uploading fields in your form

Like other types of form fields, you add a tag code into the Form area in the Contact Form 7 admin panel (Tools > Contact Form 7 in WordPress 2.7).

The tag of file upload feild is like this:

[file your-file]

As with other types of tags, ‘file’ means the type of tag, and ‘your-file’ means the name of the tag.

You can use several options with ‘file’ typed tags. To limit the max file size, use the ‘limit:’ option like this:

[file your-file limit:100000]

The unit of the digits is ‘byte.’ So ‘limit: 100000’ means that the limited max file size is approximately 100 kB.

To limit acceptable file types, use ‘filetypes’ option like this:

[file your-file filetypes:gif|png|jpg|jpeg]

List the file extensions after ‘filetypes,’ and separate them with ‘|’
(pipe) character when you set multiple file types.

You can also generate these tags with the Tag Generator, of course.

Tag generator for file

Set up file attachments with a mail

For file attachments, the new field File attachments is added in the Mail field set in the Contact Form 7 admin panel. To attach the uploaded files to the mail, put tags into this field as shown below.

File attachments:
[your-file]

As other tags used in the Mail field set, only the name (in this case, ‘your-file’) is needed. Don’t put the tag’s type or options.

file attachment to mail

If you have multiple files uploaded and want to attach them into an email, simply line them up like this:

File attachments:
[your-file][your-another-file]


Categories
Announcement WordPress Plugins

Contact Form 7 1.9

Contact Form 7 1.9 is now available!

Required WordPress version changed

New required version is WordPress 2.5 or greater. This change is needed because Contact Form 7 1.9 uses the Shortcode API which is introduced in WordPress 2.5. Using the Shortcode API allows you to redece the possibility of conflicts with other plugins.

New admin panel design compatible with WordPress 2.7

In WordPress 2.7, you can find the admin panel of Contact Form 7 under the Tools menu. Basic usage has not been changed, but it has been improved to be comparable with the new elegant admin interface of WordPress 2.7.

Contact Form 7 new admin panel

File uploading and attachment support

To explain this new feature in detail, I will need an extra post. Briefly, however, you can allow your visitors to upload their files, and then an email with an attachment of that file is sent to you. To use this feature, you need WordPress 2.7 or greater.

HTML mail support

This allows you to receive HTML formatted mail with text/html content type. If you need HTML mail, simply check the “Use HTML content type” option in the Mail fields, and then write in the Message Body text area with HTML tags.

Arabic translation

Arabic translation has been newly added. Quite amazingly, two people from other countries sent me this add-in within a very short period of time. To respect them fairly and equally, I’ll publish this, giving credit to both: Tarek Chaaban and Muhammed Lardi. Thank you very much.


Categories
Announcement WordPress Plugins

Contact Form 7 1.8.1.1

Contact Form 7 1.8.1.1 has been released. It’s including Hebrew translation by Yaron Ofer and Ukrainian translation by Andrey Kovba.

Contact Form 7 1.8.1

Contact Form 7 1.8.1.1 をリリースしています。Yaron Ofer さんのヘブライ語の言語ファイルと Andrey Kovba さんのウクライナ語の言語ファイルをパッケージに追加しています。

Categories
Announcement WordPress Plugins

Contact Form 7 1.8.1

Contact Form 7 1.8.1 is now available.

This version is compatible with the new admin interface of WordPress 2.7, so if you are trying the beta release of WordPress 2.7, I recommend you update soon to get the full benefit. WordPress 2.7 has introduced a new admin menu structure, and you can find the Contact Form 7 sub-menu under the Tools menu.

Other improvements:

  • Editable messages

    Now you can edit response messages exactly as you like. Find the Messages section at the bottom of the contact form setting page. You can also set messages per contact form unit.

  • Editable messages screenshot

  • New tag [wpcf7.remote_ip]

    If you want to know where the message has been sent from, you can use the newly introduced [wpcf7.remote_ip] tag. Put this special tag in your mail template (generally in the mail body), and it will be replaced by the sender’s client IP address. Please note, however, this can only be used in mail templates and not in forms.

  • Albanian translation

    Albanian translation by Olgi Zenullari has been added. This means that Contact Form 7 has now been translated into 29 languages.

Categories
Announcement WordPress Plugins

Contact Form 7 1.8.0.4

I released Contact Form 7 1.8.0.4. This update includes a few bug fixes and four newly added translations.

Thank you so much!

My developing of Contact Form 7 1.8.1 is late. I’m planning to release it in the beginning of next month.


Testing PollDaddy. Give it a try!


(Japanese)

Contact Form 7 1.8.0.4 をリリースしました。いくつかのバグフィックスに加え、インドネシア語、ギリシャ語、ペルシャ語、スロベニア語の各言語ファイルが新たに追加されています。

Contact Form 7 1.8.1 の開発が遅れています。来月の上旬までにはリリースする予定です。

Categories
Announcement WordPress Plugins

Contact Form 7 1.8.0.3

I released Contact Form 7 1.8.0.3. This update includes Hindi translation by Tarun Joshi and Portuguese translation by Hugo Baeta. Thank you very much!


Contact Form 7 1.8.0.3 をリリースしました。今回のアップデートは Tarun Joshi さんによるヒンディー語と Hugo Baeta さんによるポルトガル語の言語ファイルを新たに追加しています。お二人に感謝!

Categories
WordPress Plugins

FAQ for Contact Form 7 1.8

I answer two questions that I receive often since Contact Form 7 1.8 was released.

1) If you get errors like this:

Warning: imagettftext() [function.imagettftext]: Could not read font in /…/wp-content/plugins/contact-form-7/captcha/captcha.php on line 61

That’s probably the same as James reported before.

The problem is because of the FTP method used to transfer the new files being ASCII when it should be auto to cover the included font files that are binary. (I think that’s right!)

To solve the problem I downloaded the original ZIP file myself and FTP uploaded the font files to wp-content/plugins/contact-form-7/captcha/gentium/.

This issue is already mentioned in WordPress Trac ticket #7568, so anticipated to be fixed in the future version of WordPress.

2) If the CAPTCHA doesn’t show up after upgrading to 1.8.x, please make sure wp-contents/uploads/wpcf7_captcha folder exists and is writable. Since Contact Form 7 1.8, CAPTCHA images are placed in that folder.


(以下、日本語)

Contact Form 7 1.8 リリース以降に頻繁に寄せられている質問に回答します。

1) 以下のようなエラーが出ている場合は、

Warning: imagettftext() [function.imagettftext]: Could not read font in /…/wp-content/plugins/contact-form-7/captcha/captcha.php on line 61

プラグインの自動アップグレードの際にフォントファイルがテキストモードで転送されてしまっていることが原因ですので(この問題は WordPress 本体の問題ですでに WordPress Trac ticket #7568 にて報告されています)、wp-content/plugins/contact-form-7/captcha/gentium/ 以下にあるフォントファイルを FTP で(バイナリモードで!)再度転送すると直ります。

2) 1.8.x にアップグレード後、CAPTCHA が表示されなくなったという場合は、wp-contents/uploads/wpcf7_captcha が書き込み可能になっているか確認してみてください。Contact Form 7 1.8 からそこに CAPTCHA の画像を置くようになっています。

Categories
Announcement WordPress Plugins

Contact Form 7 1.8.0.2

I released Contact Form 7 1.8.0.2.

Contact Form 7 | Download

If you are seeing an error like below, please update soon.

Fatal error: Call to undefined function get_shortcode_regex() in /…/wp-content/plugins/contact-form-7/wp-contact-form-7.php on line 115

This release also includes new translation packages, Traditional Chinese translation newly created by James Wu, and Turkish translation updated by Hasan Yılmaz. Thank you very much.

(以下、日本語)

Contact Form 7 1.8.0.2 をリリースしました。以前のバージョンで下のようなエラーが出ている、という場合は、バージョンアップすることで解決するはずです。

Fatal error: Call to undefined function get_shortcode_regex() in /…/wp-content/plugins/contact-form-7/wp-contact-form-7.php on line 115

繁体字中国語の翻訳が James Wu さんにより新たに追加され、トルコ語の翻訳が Hasan Yılmaz さんにより更新されました。ありがとうございます。

Categories
Announcement WordPress Plugins

Contact Form 7 1.8.0.1

I released a relief pitcher for Contact Form 7 1.8 because of a bug I found that it causes style flaw. It’s not critical but if you are seeing strange behavior with the plugin, I recommend you to upgrade.

Plus, Chinese and Fnnish translations have been newly added. Thank you Soz and Miika!

先日公開したばかりの Contact Form 7 1.8 にスタイル関連のバグが見つかりましたので急遽中継ぎで 1.8.0.1 をリリースしました。重大な問題というわけではないですがもし気になるような変な挙動が見られたならアップグレードをおすすめします。

それと中国語とフィンランド語の翻訳が新たに追加されています。Soz さんと Miika さん、どうもありがとう!

Categories
Announcement WordPress Plugins

Contact Form 7 1.8

Contact Form 7 | Download

(日本語の説明は下にありますので転がして読んでください)

Contact Form 7 1.8 is now available at last! Please note that I’m also planning to release 1.8.1 next month, with even more functions.

The main changes of Contact Form 7 1.8 are below.

Control panel moved from Settings to Manage

This is an important change, particularly if you are a longtime user. In the past, the control panel of Contact Form 7 was in Settings > Contact Form 7. You will now find it in Manage > Contact Form 7.

In addition to this change, I extended the scope of authority to access the control panel. Administrators and editors can read and edit contact forms, while authors and contributors can read only the tag code for inserting into their posts. Whether this change is acceptable to all users is still up for debate, so your feedback would be much appreciated.

Should you find you don’t like the behavior, you can alter it by defining wpcf7_read_capability() and wpcf7_read_write_capability() in or outside the wp-contact-form-7.php. For example, with these codes you can put it back to the old way (only administrators can access the control panel):

function wpcf7_read_capability() { return 'manage_options'; }
function wpcf7_read_write_capability() { return 'manage_options'; }

WP_CONTENT_DIR, WP_CONTENT_URL and other constants

In WordPress 2.6, you can redefine the path of the directory of customizable contents, i.e. wp-content. If you haven’t heard that, read this post from planetOzh. Contact Form 7 1.8 supports this feature by referring the new constants WP_CONTENT_DIR and WP_CONTENT_URL for getting paths. Backward compatibility is also considered.

In addition, it uses these constants:

  • WP_PLUGIN_DIR
  • WP_PLUGIN_URL
  • WPCF7_PLUGIN_DIR
  • WPCF7_PLUGIN_URL
  • WPCF7_CAPTCHA_TMP_DIR
  • WPCF7_CAPTCHA_TMP_URL

The WPCF7_* contents are Contact Form 7’s original constants.

You decide paths as you wish by editing source codes and defining these constants.

Compatible with HTTPS

WordPress 2.6 includes better support for visiting the admin over HTTPS. Contact Form 7 1.8 has been updated to be able to work correctly when you are using this feature.

Moving CAPTCHA temporary image directory

In previous releases of Contact Form 7, temporary CAPTCHA images were generated in the directory wp-content/plugins/contact-form-7/captcha/tmp. However, putting the images inside the plugin’s directory could cause trouble when the plugin auto-upgrading function of WordPresss runs (which resets the writing permission of the directory).

To prevent such troubles occurring, the CAPTCHA temporary image directory has been moved to outside the plugin’s directory. Its new home is wp-contents/uploads/wpcf7_captcha.

In most cases that directory is writable, so you can use CAPTCHA without any concerns. If you don’t like the path and want to change it, you can do it by redefining the constants WPCF7_CAPTCHA_TMP_DIR and WPCF7_CAPTCHA_TMP_URL. Don’t forget to make the directory writable.

Adding id: and class: options to submit tag

This may sound like a trivial addition, but it is one many users have requested. There have always been id: and class: options for adding id and class attributes to the form control tags, but the submit tag has not had such options. These options have now, at last, been added to the submit tag in Contact Form 7 1.8.

New translation pack

A translation pack for Hungarian has been newly added. Our thanks must go to Andras Hirschler!

Plans for Contact Form 7 1.8.1

Version 1.8.1 of Contact Form 7 is in the pipeline to be released in September. The following features and improvements are likely to be a part of this version:

  • Importing and exporting of configurations;
  • Customizable messages;
  • More tags for forms and mail contents;
  • And more.