getButterfly Logo getButterfly code wrangling since 2005

You have often wondered how to create a small form and allow users to submit/upload videos on your WordPress based web site. To be honest, this module allows the user to upload any file format, such as archives, documents, audio files or graphic files.

Video Submit - Case Study

I will not be using a custom post format for this module, as the case study is based on a real life example. All video submissions will go into a separate category called “Submissions” and details will be submitted as post content.

Video Submit - Case Study Screenshot
Video Submit – Case Study Screenshot

The entire code is below and it consists of a main function – videowizard_main() – which adds the form engine to the page. It also processes the form, combines all form information and uploads the attachment. The post gets published in a special category, called “Submissions” (which can be changed to any name for that matter, just change the ID – in this case 3), as draft/private, so only an administrator can see it and publish it or further process it.

The videodjin_ functions and actions allow the posts listing to show the attached files in a separate column.

Finally, the add_shortcode('videowizard', 'videowizard_main') function creates a shortcode which can be placed on any post or page, like this [videowizard].

For brevity (and speed) purposes, I have placed this chunk of code at the end of the functions.php file. It can also be placed in a drop-in plugin. The form has no options, but it can be modified/amended/customized directly from the main function.

Subscribe to getButterfly Blog

Once a week or so we send an email with our best content. We never bug you, we just send you our latest piece of content.

If you found any value in this post, agree, disagree, or have anything to add - please do. I use comments as my #1 signal for what to write about. Read our comment policy before commenting! Comments such as "Thank you!", "Awesome!", "You're the man!" are either marked as spam or stripped from URL.

Leave a reply

Love programming?

Learn about the most amazing things. Get smarter everyday!