Uploading to user-specific folder

Formidable Forms
October 17, 2019 13:25:40
Topics: 1
Messages: 4
We are using Formidable Forms alongwith E2PDF to create a PDF version of the form submissions.

We've used a filter for Formidable Forms to move the files uploaded by the submitter into a directory which is based on their details (firstname-lastname-datestamp) in order to keep all the files organised by submitter.

I've managed to get E2DF to create the PDF in a generic "pdfs" directory, however was looking to see if I could have the PDF version stored alongside the other files they submitted. I tried using various shortcodes in both the "email" and "thanks message" areas however the PDFs aren't being created. I believe this is because these actions are being triggered *before* the form filter which is the one which creates the folders, which means that PDFs aren't being created since, at that point, the user-specific folders don't actually exist.

Would you be able to advise of a way to get the PDFs uploaded into such a user-specific folder?
October 17, 2019 16:51:28
E2Pdf
Topics: 7
Messages: 3617
Support
Hi,

If I understand correctly you have "filter" via PHP.

This is example function which will fire after creating entry (just for example). If your filter is fired after creating entry, and you are able to get Entry ID you will need just the part $pdf_path = ....



add_action('frm_after_create_entry', 'after_entry_created', 30, 2);
function after_entry_created($entry_id, $form_id) {

// Replace 19 with the Formidable Form ID
if ($form_id == '19' && $entry_id) {

// Replace 6 with your E2Pdf Template ID
$pdf_path = do_shortcode('[e2pdf-save id="6" name="' . $entry_id . '" dataset="' . $entry_id . '" output="path" apply="true"]');
if ($pdf_path) {
// Do any action by having the full path to Generated PDF
}

}
}



If it's still not what your are looking for, let us know please a bit more details so we can understand which filter your are using and we can prepare some example for you. Thank you.

We remain at your service.

We would really appreciate your feedback at WordPress.org!
October 18, 2019 09:10:51
Topics: 1
Messages: 4
Thanks for this. I already have a function which is based on the example at https://formidableforms.com/knowledgebase/frm_after_create_entry/#kb-move-and-rename-files and which successfully moves the uploaded files into a submission-specific folder based on [firstname]-[lastname]-[created-date] (with the date format being dmY) which results in something like simon-logan-18102019.

The existing shortcode I'm using in the email action is:
[e2pdf-save id="2" flatten="1" name="[6 sanitize=1]-[7 sanitize=1]-[key]" overwrite="false" dir="/path-to/wp-content/uploads/formidable/[6 sanitize=1]-[7 sanitize=1]-[created-at format="dmY"]" download="true" ]

Can I remove this from the email action and instead insert into the existing function (rather than creating another function?) I realise I might have to remove the download part.
October 18, 2019 11:06:22
E2Pdf
Topics: 7
Messages: 3617
Support
I see that you have some mistakes in your shortcode. It must work after some corrections with hook that you mentioned but you need to be sure that path is generated the same way as in your hook.

Corrected shortcode:

[e2pdf-save id="2" flatten="1" name="[6 sanitize=1]-[7 sanitize=1]-[key]" overwrite="false" dir="/path-to/wp-content/uploads/formidable/[6 sanitize=1]-[7 sanitize=1]-[created-at format='dmY']/" download="true"]

Mistake is in:
- [created-at format='dmY'] - here must be used single quotes as with double quotes wrapped the whole attribute and due security reasons it will fail in correct generation.
- dir attribute must ends with "/".

* Keep in mind also please that "/path-to/" must be the full path within "dir" parameter. i.e. /home/user/example.com/public_html/ (it can be different for your system). You can get full path by enabling "Debug" mode in "E2Pdf" -> "Settings" and checking it at "E2Pdf" -> "Debug" -> "Folders permission".

** If it will not work after correction, just check which path is generated by simply inserting string inside "Success Message". /path-to/wp-content/uploads/formidable/[6 sanitize=1]-[7 sanitize=1]-[created-at format='dmY']/ and check the difference which you have with created directory.

*** Just a tip, you can also set "name" and "flatten" attributes inside E2Pdf Template directly if needed. (screenshot attached)

If you will decide to use "do_shortcode" via PHP, it can be used in your existing hook wihout any issues but keep attention on " and '.

We remain at your service.

We would really appreciate your feedback at WordPress.org!
October 18, 2019 11:26:36
Topics: 1
Messages: 4
Hi Oleksandr

Thanks very much for this, looks like the issue was in the date formatting, so thanks for pointing that out.

I think what misled me was that I had included the path as simple text as well just so that I could debug that it was creating the path I was expecting (which it was), however it was the use of the incorrect enclosure which seemed to have been the issue. I adjusted that as you suggested and it's working now.
October 18, 2019 11:42:52
Topics: 1
Messages: 4
One last little question, is it possible for me to customise the wording of the download link which is included in the email action to be something other than simply "download"?
October 18, 2019 11:46:54
E2Pdf
Topics: 7
Messages: 3617
Support
Glad to hear that solution worked for you.

You can set "Download Link Title" inside E2Pdf Template directly (screenshot attached) or with attribute inside shortcode: button-title="PDF"

We remain at your service.

We would really appreciate your feedback at WordPress.org!
Get News and Updates
Our monthly newsletter keeps you in the loop, so you'll always be up to date with the latest news and updates about E2Pdf.
* You can update your email subscription preferences here.
All trademarks, service marks, trade names, product names, and logos appearing on this website are the property of their respective owners. The use of trademarks such as Formidable Forms®, Forminator Forms®, Gravity Forms®, JetFormBuilder®, WordPress®, WooCommerce®, WPForms® and others is solely for identification purposes (nominative use) and does not imply any affiliation, sponsorship, or endorsement by the respective trademark holders.
© 2017 - 2026, https://e2pdf.com

We use cookies to collect and analyse information on site performance and usage, to provide social media features and to enhance and customise content and advertisements. By clicking "Accept Selected", you consent to use of selected cookies according to our Cookie Policy.