I would like to use the "Video" custom field type on a form and have the video uploaded to Vimeo instead of the WordPress media library. I found this answer on your forums which recommends using the add_attachment or save_post hook to override the upload process: https://toolset.com/forums/topic/file-upload-custom-field-type-to-upload-to-amazon-s3-bucket/
Is there any more guidance or code samples you can provide? Thanks
Hi, you can see here the difference and limitations of embed fields and video fields, which are similar but not the same:
https://toolset.com/documentation/user-guides/custom-content/adding-audio-video-and-other-embedded-content-to-your-site/
For Vimeo, you should use https://toolset.com/documentation/customizing-sites-using-php/functions/#embedded-media, but please acknowledge that inserting an iFrame or the Embed HTML from sites such as YouTube, Vimeo, SlideShare is not supported.
The ticket you linked is dealing with another issue, which is to externalize media, but for that, you do not need custom code nowadays if you use some Cloud service.
I understand the embed and video fields. However, I want to customize the upload process by integrating with the Vimeo API: hidden link
How can I use Toolset to build a form that allows a user to select a file from their computer (similar to <input type=file>) and have that file uploaded to Vimeo and then store the url returned from Vimeo as a field on the post?
For that you could hook into a Toolset Form, for example, https://toolset.com/documentation/user-guides/front-end-forms/
Using cred_save_data as a hook to get the uploaded media and send it to Vimeo with some custom code, and then with custom code retrieve the Vimeo response, and deliver it back to cred_save_data to update_post_meta the field value, for example.
But for this part (talking to Viemo in the code), unless for the cred_save_data and update_post_meta methods, you'd need custom code that we cannot support as such in the forum here.
We would recommend (in case you need help with such custom code) to refer to a certified contractor:
https://toolset.com/contractors/
I can help with examples about how to use cred_save_data with update_post_meta or other WordPress hooks, but not with the part that "talks" to Vimeo.
We have a DOC here for the Forms API which can allow this https://toolset.com/documentation/programmer-reference/cred-api/
For the backend of WordPress, you would have to refer to save_post https://developer.wordpress.org/reference/hooks/save_post/
I suggest creating the first code that does this only using a hardcoded value to ensure the part that "talks" to Viemo is working.
Then, you can simply substitute the hardcoded Video URL with the Custom Field that you added with Toolset.
This could then be done either by getting the Field from the Database with get_post_meta() or, from the $_POST[field-slug]
https://developer.wordpress.org/reference/functions/get_post_meta/
https://developer.wordpress.org/reference/hooks/save_post/
Please let me know if this helps to proceed with the project.
This is enough information to get me started. Thank you!
Great, I am happy I could help along the way-
If you have doubts about the usage of the Toolset API please do not hesitate to ask us in the forum