Hi, while this is a really interesting question note that it is not related to this plugin.
According to the CF7 documentation, using the [file] mail-tag for file uploading field: will send the file name and it will attach the file to the email. It’s my understanding you want to send the file link where it’s stored on your web-site and you do not want to have it attached to the email.
My 2 cents: consider extending CF7 with a new form-tag field similar to original [file] where you overwrite the place where the value is returned (meaning the file name is replaced with the file location on the web server) to the method that sends the email in CF7 and maybe some other parts such that no file will actually be attached to the email.
Thread Starter
xanuex
(@xanuex)
Thanks for the two cents, I will definitely look into this.
The reason why I posted it here is because this plugin makes it possible to actually store the file so my thought was that the location of the file must be known too 🙂
In my other topic (https://wordpress.org/support/topic/save-files-in-a-different-folder-instead-of-the-media-library/#post-17810136) I use a function to save the file to a different folder so I so have a variable ($url) with the location.
Just not clear on how to get this variable into the function mentioned above.
I’ve seen people use cookies and global variables but I doubt if this is the way to go.
By now I realize this is a more generic question then directly related to the plugin so you may change the status and I will check your two cents out and refer to the correct plugin if I need any more help 🙂
Thanks again
You can use the following code to jump start your own solution:
add_filter('wpcf7_mail_tag_replaced_file',
function ($replaced, $submitted, $html, $mail_tag) {
$submission = WPCF7_Submission::get_instance();
$uploaded_files = $submission->uploaded_files();
$name = $mail_tag->field_name();
if ( ! empty( $uploaded_files[$name] ) ) {
$paths = (array) $uploaded_files[$name];
foreach($paths as $key => $value){
$baseValue = wp_basename($value);
$paths[$key] = '<a href="https://your-website/upload-path/' . $baseValue . '">' . $baseValue . '</a>';
}
$replaced = wpcf7_flat_join( $paths, array(
'separator' => ', ',
) );
}
return $replaced;
}, 11, 4);
This listens to email composing for file (note you might need the same for file*), gets the file, builds an HTML anchor tag with a hard coded value (change it to your website) that will be included in the email.
Have fun!