Skip Navigation

[Resolved] add cred field to uploaded file name

This thread is resolved. Here is a description of the problem and solution.

Problem:

We do employ several views so the jurors can view the application information as well as the uploaded information. Where the pre-pending of the name idea came up is for two situations

#1 often the jurors request a zip file of all the images so they can view them locally. Alot of people will view them in Adobe bridge so they can assign star ratings to them and or sort them into folders

#2 after the selections are made we attempt to clear the files out of the uploads folder- and so it would be easy to look at a folder and select files starting with a name as a way to sort them from other files uploaded during that period. There could be several hundred such applications for an average call X all the various sizes of images wordpress creates. So theres a lot of files to find.

Also if it helps we'd get the name from the cred form itsself- not from the wordpress user record.

Solution:

There isn't such a built-in feature within Toolset plugins. it needs custom codes, for example:

https://toolset.com/forums/topic/add-cred-field-to-uploaded-file-name/#post-958679

Relevant Documentation:

https://toolset.com/documentation/programmer-reference/cred-api/#cred_save_data

This support ticket is created 6 years, 5 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 5 replies, has 3 voices.

Last updated by Luo Yang 6 years, 4 months ago.

Assisted by: Luo Yang.

Author
Posts
#957386

I have a form used by a small museum that is used for artists to submit applications and images for various juried shows. We ask the submitters to include their name in the image filenames but mostly they don't. Is there a way we can prepend the name field from the cred form to the images as they are uploaded and saved. The images are uploaded to a repeating image field in the form

#957913

I first prepared a long reply with a Custom Code solution but I believe, I do not yet have enough informations here.

I think, the main issue you deal with, is that you have no idea who uploaded what file, unless you go to each post, edit it, check the author, check the file name, etc etc.

That is very annoying.

What I can suggest is, instead of dealing with a lot of custom code, and risky updates to the media data (which is not as easy as it seems), to solve this problem, create a front end admin page where you can see exactly who uploaded what, if you need, even by User, or content of those fields.

That would be easily possible by creating Views, that display the posts created and their Repeating fIelds as raw values, and you can there even "prepend" those with the author name!

Would that help to simplify the process?
Bound with Forms, you can even have the edit links there, in a table, all ready to be sorted, filtered and edited at one click (our a few more).

If that is not good solution - yes you can update the attachments Titles or even URL's but the uploads are done with Form's AJKAX, which has not many filters to apply on.
Later, you would need to both update the Attachment data AND the field data, since now that is too late to upload the media with the updated data to the database.

So, the code needed here could be complex and eventually we are overthinking - would such an admin panel help to solve the problem?

I can help you with informations how to make it.

#958305

Beda thanks so much for the thoughtful response.

We do employ several views so the jurors can view the application information as well as the uploaded information. Where the pre-pending of the name idea came up is for two situations

#1 often the jurors request a zip file of all the images so they can view them locally. Alot of people will view them in Adobe bridge so they can assign star ratings to them and or sort them into folders

#2 after the selections are made we attempt to clear the files out of the uploads folder- and so it would be easy to look at a folder and select files starting with a name as a way to sort them from other files uploaded during that period. There could be several hundred such applications for an average call X all the various sizes of images wordpress creates. So theres a lot of files to find.

Also if it helps we'd get the name from the cred form itsself- not from the wordpress user record.

Steve

#958679

Hello,

There isn't such a built-in feature within Toolset plugins. it needs custom codes, for example, I assume we are talking about a Toolset form for creating "application" post, after user submits this form with images, all images are attached to the new "application" post, you can try these:

1) Use action hook cred_save_data to trigger a custom PHP function
https://toolset.com/documentation/programmer-reference/cred-api/#cred_save_data

2) In this PHP function, get all attached images with WordPress function get_attached_media (),
https://codex.wordpress.org/Function_Reference/get_attached_media

If there is only one multiple instance image field, you can also use Types function to get the image URLs:
https://toolset.com/documentation/customizing-sites-using-php/functions/#image

And put them into a zip file:
hidden link

use the "name field" value + post ID value as the zip file name, so the zip file name should be unique in your website.

Create a custom URL field, use above zip file URL as the field value

3) In the single "application" post, Display URL field value in front-end, so the jurors can download the zip file of each "application" post

#1069459

Thanks luo - I'll see if i cant create that function

Best

#1069582

You are welcome