New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
β π π Feature Request: Send E-Mail Form Attachments as Regular E-Mail Attachments instead of a link that is saved in the ftp server - [ED-2192] #4868
Comments
+1 |
Currently, this feature is not supported, but we will look into it in the future if we see a large demand for it. for now, you can use this class which will add the uploads as attachments to the email: See this updated version which allows removing the files from the server after they are sent: #4868 (comment) <?php
/**
* Class Elementor_Form_Email_Attachments
*
* Send Elementor Form upload field as attachments to email
*/
class Elementor_Form_Email_Attachments {
public $attachments_array = [];
public function __construct() {
add_action( 'elementor_pro/forms/process', [ $this, 'init_form_email_attachments' ], 11, 2 );
}
/**
* @param \ElementorPro\Modules\Forms\Classes\Form_Record $record
* @param \ElementorPro\Modules\Forms\Classes\Ajax_Handler $ajax_handler
*/
public function init_form_email_attachments( $record, $ajax_handler ) {
// check if we have attachments
$files = $record->get( 'files' );
if ( empty( $files ) ) {
return;
}
// Store attachment in local var
foreach ( $files as $id => $files_array ) {
$this->attachments_array[] = $files_array['path'][0];
}
// if local var has attachments setup filter hook
if ( 0 < count( $this->attachments_array ) ) {
add_filter( 'wp_mail', [ $this, 'wp_mail' ] );
add_action( 'elementor_pro/forms/new_record', [ $this, 'remove_wp_mail_filter' ], 5 );
}
}
public function remove_wp_mail_filter() {
$this->attachments_array = [];
remove_filter( 'wp_mail', [ $this, 'wp_mail' ] );
}
public function wp_mail( $args ) {
$args['attachments'] = $this->attachments_array;
return $args;
}
}
new Elementor_Form_Email_Attachments(); Thanks for the feedback. |
Thank you for the code, do we put this in the CSS box of the elementor widget? |
I asked Elementor Support how to install this: "Hi, nope, I guess this must be added to the theme's functions.php file at the end of it.Best regards. |
It's here and labeled so no need to keep it open if we get many new requests then .... thanks. |
Please make this happen, I have bought E Pro for the form widget but now I'm using Form7 instead while waiting for that issue to be resolved. |
Hello! This Code is great for me, but I have a question: With this code the attachements are in my boxemail but these are in FTP too... Any posibility these files arenΒ΄t in FTP? I received a lot of attachements and I need remove these all weeks. Thank you! |
+1 |
................................................................................ What about the code is not an option! need to solve this problem. I bought about the version and I suffer with it for a long time and more than once wrote silence only in response. Dear developers, you sell your creation should work out as this product is paid. |
Hi bainternet, |
good day unfortunately there is nothing fixed when attaching the file, they are still loaded on the FTP server in the folder uploads/elementor/forms Π΄ΠΎΠ±ΡΡΠΉ Π΄Π΅Π½Ρ ΠΊ ΡΠΎΠΆΠ°Π»Π΅Π½ΠΈΡ Π½Π΅Ρ Π½ΠΈΡΠ΅Π³ΠΎ Π½Π΅ ΠΈΡΠΏΡΠ°Π²ΠΈΠ»ΠΈ ΠΏΡΠΈ ΠΊΡΠ΅ΠΏΠ»Π΅Π½ΠΈΠΈ ΡΠ°ΠΉΠ»Π° ΠΎΠ½ΠΈ Π²ΡΠ΅ ΡΠ°Π²Π½ΠΎ Π·Π°Π³ΡΡΠΆΠ°ΡΡΡΡ Π½Π° ΡΡΠΏ ΡΠ΅ΡΠ²Π΅Ρ Π² ΠΏΠ°ΠΏΠΊΡ uploads/elementor/forms |
good day unfortunately there is nothing fixed when attaching the file, they are still loaded on the FTP server in the folder uploads/elementor/forms
Π΄ΠΎΠ±ΡΡΠΉ Π΄Π΅Π½Ρ ΠΊ ΡΠΎΠΆΠ°Π»Π΅Π½ΠΈΡ Π½Π΅Ρ Π½ΠΈΡΠ΅Π³ΠΎ Π½Π΅ ΠΈΡΠΏΡΠ°Π²ΠΈΠ»ΠΈ ΠΏΡΠΈ ΠΊΡΠ΅ΠΏΠ»Π΅Π½ΠΈΠΈ ΡΠ°ΠΉΠ»Π° ΠΎΠ½ΠΈ Π²ΡΠ΅ ΡΠ°Π²Π½ΠΎ Π·Π°Π³ΡΡΠΆΠ°ΡΡΡΡ Π½Π° ΡΡΠΏ ΡΠ΅ΡΠ²Π΅Ρ Π² ΠΏΠ°ΠΏΠΊΡ uploads/elementor/forms
https://prnt.sc/m8jffa
β¦Π‘ΡΠ΅Π΄Π°, 16 ΡΠ½Π²Π°ΡΡ 2019, 17:00 +03:00 ΠΎΡ Christian ***@***.***>:
Hi bainternet,
Does this mean that it has been resolved?
Thank you
β
You are receiving this because you commented.
Reply to this email directly, view it on GitHub , or mute the thread .
--
ΠΠ»Π΅ΠΊΡΠ΅ΠΉ Π’Π΅Π½ΡΠΊΠΎΠ²
|
Adding this version of the class which lets you remove the files from the server after they are sent. <?php
/**
* Class Elementor_Form_Email_Attachments
*
* Send Elementor Form upload field as attachments to email
*/
class Elementor_Form_Email_Attachments {
// Set to true if you want the files to be removed from
// the server after they are sent by email
const DELETE_ATTACHMENT_FROM_SERVER = false;
public $attachments_array = [];
public function __construct() {
add_action( 'elementor_pro/forms/process', [ $this, 'init_form_email_attachments' ], 11, 2 );
}
/**
* @param \ElementorPro\Modules\Forms\Classes\Form_Record $record
* @param \ElementorPro\Modules\Forms\Classes\Ajax_Handler $ajax_handler
*/
public function init_form_email_attachments( $record, $ajax_handler ) {
// check if we have attachments
$files = $record->get( 'files' );
if ( empty( $files ) ) {
return;
}
// Store attachment in local var
foreach ( $files as $id => $files_array ) {
$this->attachments_array[] = $files_array['path'][0];
}
// if local var has attachments setup filter hook
if ( 0 < count( $this->attachments_array ) ) {
add_filter( 'wp_mail', [ $this, 'wp_mail' ] );
add_action( 'elementor_pro/forms/new_record', [ $this, 'remove_wp_mail_filter' ], 5 );
}
}
public function remove_wp_mail_filter() {
if ( self::DELETE_ATTACHMENT_FROM_SERVER ) {
foreach ( $this->attachments_array as $uploaded_file ) {
unlink( $uploaded_file );
}
}
$this->attachments_array = [];
remove_filter( 'wp_mail', [ $this, 'wp_mail' ] );
}
public function wp_mail( $args ) {
$args['attachments'] = $this->attachments_array;
return $args;
}
}
new Elementor_Form_Email_Attachments(); Just set the const DELETE_ATTACHMENT_FROM_SERVER = false; to const DELETE_ATTACHMENT_FROM_SERVER = true; |
+1 |
2 similar comments
+1 |
+1 |
I added this code to my function.php file. |
@joylauu
And this to construct:
Full-Class:
|
@crazypsycho Does your code really remove attachment for email2 recipient? We just need to Elementor won't send attachments to email2 who is usually sender of form. |
I saw this code posted to another user with my same issue but It's not working. I need to keep the original user file upload name. I'm not saving it to my server so it dupes don't matter and I'm only accepting docx, doc and pdf with captcha so I'm not worried about the other issues. It's imperative that I have the original file name /**
}, 10, 4 ); |
+1 !!! |
Hello @nicholaszein .. I am very happy that finally any of you from Elementor is responding. It would be really nice if that would happen more often. |
Hi @nicholaszein - While I appreciate your response, having something on a "roadmap" without any eta means nothing other than that there is no commitment. This could take another 2-3 years and you could always say that "it's on the roadmap" ... that's like the authorities saying that they will fix the main road in your city at some point ... and until then you have to drive 2 hours extra every single day ... how would you like such a response? Would you take that as a reliable response? I also would like to add another point: I appreciate topics being merged - as along as they truly are overlapping to a degree that they are close to the same. As far as I can tell #9181 was quite a different issue ... unless you guys actually include both sets of requirements when you implement it... |
Hello, I have a question regarding the workaround. Everything works fine beside, that for the second email with the [elementor_form_no_attachment] text, it does not delete the text when there is no attachment. So the email has the text [elementor_form_no_attachment] when there is no attachment. When there is one then it deletes the message correctly. We added the following code but I don't understand why this is not working. Thx in advance.
|
Hello, i told the AI to improve the code and it gave me this: `
`
Im no coder so.. whats your opinions? |
5 years later and still not implemented in Elementor Core (despite 400 developers according to official website)... that is why Elementor is digging its own grave.. |
please put this option in the widget! there is no way it is not natively expected by Elementor. it's frustrating every time to look for the solution. |
This code works for me, thanks! But it is possible to get more than one file as attachment? |
+1 (!) |
Although it's pointless since nobody from elementor comes here. +1 |
I really dont understand why this is not already implemented. Elementor promised to have it this year, it seems it is all pushed back every time. Please Elementor, update us on this essential function! |
Can Elementor add this to their update, it's been 5 years since I asked for this. |
5 years for basic functionality... it becomes hilarious if it wasn't so sad.... |
Need it too ! |
knock knock Elementor. The year 2023 started so promising... big online show... yesss we are going to bring your long awaited functionality. And we are going to be more interactive with the feedback from our users on Github... |
How can i add more than one file? |
The Elementor Extension dynamic.ooo has this feature ready: https://help.dynamic.ooo/en/articles/4954053-dynamic-email-for-elementor-pro-form#h_ede9c7e452 |
This feature is already in beta of Pro. At last 5 years later! |
YAY! To quote Queen: "...it finally happened - I'm slightly mad!" ;-) |
Hello everyone! We have great news! π π’ We're happy to announce that this feature was released with Elementor Pro v3.18.0! π₯³β Feel free to check it out and update your plugin to the new version!
Cheers π₯ |
Prerequisites
Wordpress & Elementor Pro
What problem is your feature request going to solve? Please describe.
Elementor Contact Form email attachments should not go to ftp drive and sent as a link. It is annoying and takes too long to delete.
Describe the solution you'd like
We would suggest Elementor Email Forms should be sent as E-Mail Attachments instead of saving to ftp server as a link. It is very annoying and counter intuitive for us to have to go to the ftp drive to retrieve/delete images a customer sends to us via form attachments. It would be best if either they can be just sent as an "attachment" or a folder you could create in wp-admin > elementor > email attachments. Either way would be better than the system now. But a regular old fashioned email attachment is preferred.
Describe alternatives you've considered
Above is all
Additional context
None
The text was updated successfully, but these errors were encountered: