Skip Navigation

[Resolved] File upload drag/drop feature from CRED

This support ticket is created 6 years, 7 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
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 3 replies, has 2 voices.

Last updated by Christian Cox 6 years, 7 months ago.

Assisted by: Christian Cox.

Author
Posts
#649749

Dear Sir/Madam,

I think file upload drag/drop feature has been requested for a long time ago, at least more then 1 year I know. It is must for a site with image gallery, otherwise, upload file one by one is not user-friendly. Some of the sites we have to give up using Toolset as it sill not yet supported the file upload drag/drop feature while it is the requirement for the clients.

Is it possible to have some script for us to record the relationship if we insert other plugins for the drag/drop function? If I can have a custom code to allow a customer to upload the files by drag/drop and return with an id and we can store this id via the CRED, I think it may help to view the gallery by calling the id.

Do you have any suggestion?

Best regards,

Kelvin.

#650066

Hi, we currently offer the cred_save_data API that will allow you to save some custom field values when the form is submitted, like this:

$post_id = 12345;
$files = array('<em><u>hidden link</u></em>', '<em><u>hidden link</u></em>', '<em><u>hidden link</u></em>');
foreach( $files as $file ) {
  add_post_meta( $post_id, 'wpcf-repeating-image-field', $file );
});

So if you know the file URLs when the CRED form is submitted, you can use this method to update a repeating image field. The problem with using another plugin file to handle uploads is that it may not be easy to save those file URLs somewhere you can access them during cred_save_data. There is no CRED JavaScript API, so I don't have any code to offer to help with that part. I can help you use the add_post_meta function in a cred_save_data hook, if you can provide a variable that holds an array of the uploaded file URLs.

More CRED API documentation here:
https://toolset.com/documentation/programmer-reference/cred-api/#cred_save_data

#680116

Dear Christian Cox,

When I create a post using CRED, is there any post id I can get or I can only get the post id when cred_save_data is performed? If I can have the post id, then I can make a drag/drop associated with the post id.

Best regards,

Kelvin.

#680237

There is no new post ID until the CRED form has been submitted and the post has been created, so I'm not sure what you're asking for exactly. If you're asking how to predict the new post's ID before the form is submitted, it is not possible. The cred_save_data hook is probably the first opportunity you will have to access the new post ID. This is the main challenge with using a 3rd-party file uploader as I mentioned earlier:

The problem with using another plugin file to handle uploads is that it may not be easy to save those file URLs somewhere you can access them during cred_save_data.