Skip Navigation

[Resolved] CRED form, upload file, email the file – but not save file to wordpress

This support ticket is created 3 years, 6 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 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

This topic contains 1 reply, has 2 voices.

Last updated by Shane 3 years, 6 months ago.

Assisted by: Shane.

Author
Posts
#2051605

Using a from, I want to create a CPT record - this is fine.
I also want to upload files - But I don't want the files to be included in the CPT record, or added to WP media

Have added the generic fields in the form ok. cred_form_validate has access to the files - but I'm thinking it's going to easier to add the fields to the CPT and then delete the files from media.

What is the best way to delete the files from WP media after upload is complete in cred_save_data?

#2051941

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Terry,

Thank you for getting in touch.

I also want to upload files - But I don't want the files to be included in the CPT record, or added to WP media

Not sure what you mean by this, is it that you want the file to be uploaded in a completely different directory?

What is the best way to delete the files from WP media after upload is complete in cred_save_data?

You can do this with the cred_save_data hook however it would require that you employ the use of custom code to achieve.

What I mean is that you're going to have to get the ID of the file from the url using the function below.
https://developer.wordpress.org/reference/functions/attachment_url_to_postid/

Then delete that file once you've gotten the ID using this function below.
https://developer.wordpress.org/reference/functions/wp_delete_attachment/

Please let me know if this was able to help.
Thanks,
Shane