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( 'before_insert_attachment_callback', 'example_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!!!

Στιγμιότυπα

  • screenshot-1.jpg

Εγκατάσταση

  1. Upload the entire folder to the /wp-content/plugins/ directory.
  2. Activate the plugin through the ‘Plugins’ menu in WordPress.

After that check Media Library for uploaded files.

Κριτικές

2 Δεκεμβρίου 2021
I am getting error while submitting to CF7. Note: I am trying to upload MP3 files <pre>fatal error: Array ( [type] => 1 [message] => Uncaught Error: Call to undefined function wp_read_audio_metadata() in /home/theuxm/html/wp-admin/includes/image.php:489 Stack trace: #0 /home/theuxm/html/wp-content/plugins/store-file-uploads-for-contact-form-7/store-file-uploads-for-contact-form-7.php(39): wp_generate_attachment_metadata() #1 /home/theuxm/html/wp-content/plugins/store-file-uploads-for-contact-form-7/store-file-uploads-for-contact-form-7.php(55): nmr_create_attachment() #2 /home/theuxm/html/wp-includes/class-wp-hook.php(305): nmr_on_before_cf7_send_mail() #3 /home/theuxm/html/wp-includes/class-wp-hook.php(327): WP_Hook->apply_filters() #4 /home/theuxm/html/wp-includes/plugin.php(518): WP_Hook->do_action() #5 /home/theuxm/html/wp-content/plugins/contact-form-7/includes/submission.php(617): do_action_ref_array() #6 /home/theuxm/html/wp-content/plugins/contact-form-7/includes/submission.php(86): WPCF7_Submission->before_send_mail() #7 /home/theuxm/html/wp-content/plugins/contact-form-7/includes/submission.php(27): WPCF7_Submission->proceed() #8 [file] => /home/theuxm/html/wp-admin/includes/image.php [line] => 489 ) </pre>
3 Μαρτίου 2021
Thanks! I spent a day wondering why the temporary file was not longer there then another day finding out that CF7 is moving that file. So this is exactly what I was trying to figure out. It does look like files could be overwritten if they are uploaded with an existing name. You can probably do something like the following to ensure files get unique names and are not overwritten. // Get the path to the upload directory. $wp_upload_dir = wp_upload_dir(); $upload_path = $wp_upload_dir['path']; $unique_filename = wp_unique_filename($upload_path, basename($filename)); $attachFileName = $upload_path . '/' . $unique_filename; copy($filename, $attachFileName); // Prepare an array of post data for the attachment. $attachment = array( 'guid' => $attachFileName, 'post_mime_type' => $filetype['type'], 'post_title' => preg_replace('/\.[^.]+$/', '', $unique_filename), 'post_content' => '', 'post_status' => 'inherit' );
Ανάγνωση όλων των 4 κριτικών

Συνεισφέροντες & Προγραμματιστές

“Store file uploads for Contact Form 7” είναι λογισμικό ανοιχτού κώδικα. Οι παρακάτω έχουν συνεισφέρει στη δημιουργία του.

Συντελεστές

Το “Store file uploads for Contact Form 7” έχει μεταφραστεί σε 5 γλώσσες. Ευχαριστούμε τους μεταφραστές για τις συνεισφορές τους.

Μεταφράστε το “Store file uploads for Contact Form 7” στην γλώσσα σας.

Ενδιαφέρεστε για την ανάπτυξη;

Περιηγηθείτε στον κώδικα, ανατρέξτε στο αποθετήριο SVN ή εγγραφείτε στο αρχείο καταγραφής αλλαγών ανάπτυξης μέσω RSS .

Σύνοψη αλλαγών

1.2.2

Add support for changing attachment attributes using nmr_before_insert_attachment filter

1.2.1

  • Added support for media uploads (including mp3)

1.2.0

  • Added filter nmr_create_attachment_file_name and action nmr_create_attachment_id_generated

1.1.0

  • Contact Form 7 WPCF7_Submission::get_instance()->uploaded_files changed in CF7 5.4, so adjustments in this plugin were needed.

1.0.0

  • First version.