Skip Navigation

[Resolved] Custom Field to Upload to Vimeo

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

Problem:
If I would want a custom field in my WordPress install to push its contents to Vimeo, or any other service, and then update itself with data received back from that service (or, update another field), how would I approach this?

Solution:
This requires custom code since Toolset features no direct integration with other services to upload or store and communicate data.

You could use the moment when WordPress saves the post - or a Toolset Form, to hook some custom code that using the 3rd party API interacts with that 3rd party the way you want.

Here we explain a short case of a solution - however, we cannot provide the code that is related to the 3rd party itself. This would be subject to your own study or contractors work.
https://toolset.com/forums/topic/video-custom-field-to-upload-to-vimeo/#post-1439747

This support ticket is created 5 years, 4 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
- - 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00
- - - - - - -

Supporter timezone: Asia/Ho_Chi_Minh (GMT+07:00)

This topic contains 5 replies, has 2 voices.

Last updated by Beda 5 years, 4 months ago.

Assisted by: Beda.

Author
Posts
#1438993

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

#1439301

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.

#1439697

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?

#1439747

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.

#1440209

This is enough information to get me started. Thank you!

#1443947

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