[WordPress] 外掛分享: Store file uploads for Contact Form 7

首頁外掛目錄 › Store file uploads for Contact Form 7
1,000+
安裝啟用
★★★★★
5/5 分(6 則評價)
649 天前
最後更新
問題解決
WordPress 4.9+ v1.2.3 上架:2020-02-27

內容簡介

預設狀態下,Contact Form 7 不會保留通過其聯絡表單發送的數據。
雖然像 Flamingo 這樣的外掛會保存這些數據,但上傳的文件並不會添加到媒體庫。
這個外掛會在 CF7 發送電子郵件之前將上傳的文件保存到媒體庫中。
此外,該外掛會觸發一個事件,其中包含完整的文件路徑和名稱。
你可以通過訂閱 nmr_create_attachment_file_name 過濾器來獲取和/或更新附件添加到媒體庫之前的數據。

// 過濾器回呼函數。
function example_callback( $file_name ) {
//(可能)修改 $file_name。
return $file_name;
}
add_filter( 'nmr_create_attachment_file_name', 'example_callback', 10, 1 );

你可以通過訂閱 nmr_before_insert_attachment 過濾器來更改附件屬性:標題和描述是「post_excerpt」和「post_content」。
有關其他屬性,請參閱 wp_insert_attachment 的文檔。

// 過濾器回呼函數。
function before_insert_attachment_callback( $attachment ) {
//(可能)修改 $attachment 陣列。
return $attachment;
}
add_filter( 'before_insert_attachment_callback', 'example_callback', 10, 1 );

如果你對附件的其他詳細信息感興趣,例如附件的 URL,則此外掛會發送最終的附件 ID。
你可以訂閱 nmr_create_attachment_id_generated 事件以做出回應。

// 事件回呼函數。
function example_callback_id_generated( $attachment_id ) {
//(可能)對這些引數執行某些操作。
$url = wp_get_attachment_url( $attachment_id );
}
add_action( 'nmr_create_attachment_id_generated', 'example_callback_id_generated', 10, 1 );

文件和支援

請查看 WordPress.org 上的 支援論壇。如果找不到任何與你特定問題相關的主題,請發佈一個新主題。

Store file uploads for Contact Form 7 需要您的支持

在沒有像你一樣的用戶貢獻的情況下,這個免費外掛很難繼續開發和支援。如果你喜歡使用「Store file uploads for Contact Form 7」並找到它很有用,請考慮捐贈。你的捐贈將有助於鼓勵和支持外掛的持續發展以及更好的用戶支援。

隱私通知

使用預設配置時,此外掛本身不會:

秘密跟踪用戶;
將任何用戶個人數據寫入數據庫;
發送數據到外部服务器;
使用 Cookie。

但是,它會通過 Contact Form 7 將上傳的文件存儲在 WordPress 媒體庫中。
請確保你的網站用戶知道這一點!!!

外掛標籤

開發者團隊

⬇ 下載最新版 (v1.2.3) 或搜尋安裝

① 下載 ZIP → 後台「外掛 › 安裝外掛 › 上傳外掛」
② 後台搜尋「Store file uploads for Contact Form 7」→ 直接安裝(推薦)
📦 歷史版本下載

原文外掛簡介

By default, Contact Form 7 dose not keep data it sends trough it’s contact forms.
While plugins like Flamingo save that data, uploaded files are not added to Media Library.
This plugin will save uploaded files to Media Library before email is sent by CF7.
This plugin will raise an event with the the full file path & name.
Subscribe to nmr_create_attachment_file_name filter to get and/or update data before attachment is added to media library.
// The filter callback function.
function example_callback( $file_name ) {
// (maybe) modify $file_name.
return $file_name;
}
add_filter( 'nmr_create_attachment_file_name', 'example_callback', 10, 1 );

Subscribe to nmr_before_insert_attachment filter to be able to change attachment attributes: caption and description are ‘post_excerpt’ and ‘post_content’.
For other attributes, check documentation for wp_insert_attachment.
// The filter callback function.
function before_insert_attachment_callback( $attachment ) {
// (maybe) modify $attachment array.
return $attachment;
}
add_filter( 'nmr_before_insert_attachment', 'before_insert_attachment_callback', 10, 1 );

Optionally, subscribe to nmr_should_skip_save_attachment_to_media_library filter to be able to skip saving the attachment to media library: return true to skip, false is the default behaviour that saves the attachment to media library. Filter nmr_before_insert_attachment will not be called if skip was true.
// The filter callback function.
function skip_media_library_callback( $skip_save_to_media_library ) {
// return true to skip saving to Media Library, false to save.
return true;
}
add_filter( 'nmr_should_skip_save_attachment_to_media_library', 'skip_media_library_callback', 10, 1 );

This plugin will send the final attachment id if you are interested in getting other details, like attachment url.
Listen to nmr_create_attachment_id_generated action.
// The action callback function.
function example_callback_id_generated( $attachment_id ) {
// (maybe) do something with the args.
$url = wp_get_attachment_url( $attachment_id );
}
add_action( 'nmr_create_attachment_id_generated', 'example_callback_id_generated', 10, 1 );

Docs & Support
Check the support forum on WordPress.org. If you can’t locate any topics that pertain to your particular issue, post a new topic for it.
Store file uploads for Contact Form 7 Needs Your Support
It is hard to continue development and support for this free plugin without contributions from users like you. If you enjoy using -Store file uploads for Contact Form 7- and find it useful, please consider making a donation. Your donation will help encourage and support the plugin’s continued development and better user support.
Privacy Notices
With the default configuration, this plugin, in itself, does not:

track users by stealth;
write any user personal data to the database;
send any data to external servers;
use cookies.

It will, however store uploaded files trough Contact Form 7 in WordPress Media Library.
Make sure your website users are aware of this fact!!!

延伸相關外掛

文章
Filter
Apply Filters
Mastodon