Video Uploader Form does not work properly

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
steveryan
Forum Newbie
Posts: 13
Joined: Wed Aug 05, 2015 5:19 pm

Video Uploader Form does not work properly

Post by steveryan »

Hello,

I am building a video upload form for my wordpress site. This uploader will enable users to upload mp4 video (and other video formats) from the front end.

All I did was copy and paste the code from the uploader that comes standard with the BeeTube theme we are using. The reason why I'm doing this is because I want the uploader on it's own page and I don't want people to have to "Submit a Post". It's not in line with what we are trying to do. I just want people to click on an "Upload" link that will take them directly to an uploader. We don't want the uploader to say anything about making a post. It's supposed to be a simple uploader.

I'm trying to edit the code so that the uploader works the way it's supposed to. I'm having problems doing this.

This uploader has several fields. It's also supposed to create the post automatically.

I have two problems:

1. It is not creating the post.
2. The drop-down menu for the video categories is not displaying.

If these two features work correctly, the form should also grab the video URL from the media gallery and insert it into the "Video File" field within the post edit page so that the HTML5 video player we are using will display the video instantly on the front end for public view.

If there's any way that someone can help me get this working I would be so grateful.

Here is the code I am trying to edit.

Code: Select all


<?php
            $current_user = wp_get_current_user();
            ?>
            <div id="postbox">
            <form id="new_thread" name="new_thread" method="post" action="" enctype="multipart/form-data">	
			<label for="comment">Video Title</label>
            <input type="text" id="author" value="" name="video_title" placeholder="Video Title" />
			<br/>	
			<label for="comment">Post Description</label>
            <textarea id="comment" name="video_description"></textarea>
			<br />
			
		<div class="video-options">
				<input type="radio" name="video_options" value="video_custom" class="video-custom" />
				<label for="comment">Video Uploader</label>
			</div>	
						
			<div class="video-custom vid-option">
				<label for="comment">Video Uploads Only</label>
				<br/>
				<input type="file" name="upload_attachment[]" id="user-image-featured" size="20">
				<p>
				<br/>
			</div>
			
			<div class="video-embed-code vid-option">
				<label for="comment">Video Embed Code</label>
				<textarea id="comment" name="video_embed_code"></textarea>
				<p>Paste the raw video code to here, such as <-object->, <-embed-> or <-iframe-> code.</p>
				<br/>
			</div>
			<?php
				$seoMeta = get_option('jtheme_seo_metaon');
				if($seoMeta == true){ ?>
			<div class="video-seo-block">
				<label for="comment">Meta Title</label>
				<textarea id="comment" name="seo_title"></textarea>
				<p>IF you want to put your custom meta Title then put here otherwise your post title will be the default meta Title</p>
				<br/>
			</div>
			
			<div class="video-seo-block">
				<label for="comment">Meta Description</label>
				<textarea id="comment" name="seo_description"></textarea>
				<p>IF you want to put your custom meta description then put here otherwise your post description will be the default meta description</p>
				<br/>
			</div>
			
			<div class="video-seo-block">
				<label for="comment">Meta Keywords</label>
				<textarea id="comment" name="seo_keywords"></textarea>
				<p>IF you want to put your custom meta Keywords then put here otherwise your post TAGS will be the default meta Keywords</p>
				<br/>
			</div>
			<?php } ?>
			<div class="video-cat">
				<label for="comment">Video Categories</label><br/>
				<?php wp_dropdown_categories( 'show_option_none=Category&tab_index=4&taxonomy=category' ); ?>
			</div>
			
			 <!-- images -->
			<div class="video-img">
				<label for="images">Featured Image:</label><br/>
				<input type="file" name="upload_attachment[]" id="user-image-featured" size="20">
			</div>
			
			<div class="video-cat">
				<label for="comment">Video Layout</label><br/>
				<select name="video_layout">
					<option selected="selected" value=""></option>
					<option value="standard">Standards</option>
					<option value="full-width">Full Width</option>
				</select>
			</div>
			
			<label for="comment">Video Tags</label>
            <input type="text" id="author" value="" name="video_tags" placeholder="Video Tags" />
					       
            <!-- Submit button-->
            <br />
            <input type="submit" value="Save Post" tabindex="5" id="thread_submit" name="thread_submit" class="thread-button" />

            <input type="hidden" name="insert_post" value="post" />

            <?php wp_nonce_field( 'new_thread' ); ?>

            </form>

            </div>
steveryan
Forum Newbie
Posts: 13
Joined: Wed Aug 05, 2015 5:19 pm

Re: Video Uploader Form does not work properly

Post by steveryan »

I've simplified the code down to only the bare elements that I need.

I'm taking this code and pasting it directly into the "Text" area within the wordpress page in the editor.

Is that why this isn't displaying the categories?

Code: Select all

<?php
            $current_user = wp_get_current_user();
            ?>
            <div id="postbox">
            <form id="new_thread" name="new_thread" method="post" action="" enctype="multipart/form-data">      
                        <label for="comment">Video Title</label>
            <input type="text" id="author" value="" name="video_title" placeholder="Video Title" />
                        <br/>   
                        <label for="comment">Post Description</label>
            <textarea id="comment" name="video_description"></textarea>
                        <br />
                        
                <div class="video-options">
                                <input type="radio" name="video_options" value="video_custom" class="video-custom" />
                                <label for="comment">Video Uploader</label>
                        </div>  
                                                
                        <div class="video-custom vid-option">
                                <label for="comment">Video Uploads Only</label>
                                <br/>
                                <input type="file" name="upload_attachment[]" id="user-image-featured" size="20">
                                <p>
                                <br/>
                        </div>
 
                        <?php
                        <div class="video-cat">
                                <label for="comment">Video Categories</label><br/>
                                <?php wp_dropdown_categories( 'show_option_none=Category&tab_index=4&taxonomy=category' ); ?>
                        </div>
                        
            <!-- Submit button-->
            <br />
            <input type="submit" value="Save Post" tabindex="5" id="thread_submit" name="thread_submit" class="thread-button" />

            <input type="hidden" name="insert_post" value="post" />

            <?php wp_nonce_field( 'new_thread' ); ?>

            </form>

            </div>
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Video Uploader Form does not work properly

Post by Christopher »

Did you look at the source to the page generated to see what wp_dropdown_categories() is outputting??
(#10850)
steveryan
Forum Newbie
Posts: 13
Joined: Wed Aug 05, 2015 5:19 pm

Re: Video Uploader Form does not work properly

Post by steveryan »

Christopher wrote:Did you look at the source to the page generated to see what wp_dropdown_categories() is outputting??
No, I didn't. I don't completely understand what that means. The drop-down menu is supposed to output several video categories that we have created. For example: Drama, Comedy, Sports, Sci-Fi, etc... It's supposed to display all of our categories.

I studied HTML and web design in college but not in depth. This is complex stuff for me.

The drop-down menu for the categories won't even appear on the page.

The code was copy and pasted from the default uploader that came with our theme. What I don't understand is why I can't just take this code and insert it into the "Text" field in a new page and get it to function.

In know that I'm probably missing some obvious stuff here. Maybe what I'm trying to do is actually way above my head or requires a ton of work that I won't be able to do.

It just seems to me that I should be able to edit the code so that it all functions the way the default uploader does.
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Video Uploader Form does not work properly

Post by Christopher »

steveryan wrote:
Christopher wrote:Did you look at the source to the page generated to see what wp_dropdown_categories() is outputting??
No, I didn't. I don't completely understand what that means. The drop-down menu is supposed to output several video categories that we have created. For example: Drama, Comedy, Sports, Sci-Fi, etc... It's supposed to display all of our categories.
I mean, when you run the page and then View Source, what HTML is generated by wp_dropdown_categories() ?
(#10850)
steveryan
Forum Newbie
Posts: 13
Joined: Wed Aug 05, 2015 5:19 pm

Re: Video Uploader Form does not work properly

Post by steveryan »

Christopher wrote:
steveryan wrote:
Christopher wrote:Did you look at the source to the page generated to see what wp_dropdown_categories() is outputting??
No, I didn't. I don't completely understand what that means. The drop-down menu is supposed to output several video categories that we have created. For example: Drama, Comedy, Sports, Sci-Fi, etc... It's supposed to display all of our categories.
I mean, when you run the page and then View Source, what HTML is generated by wp_dropdown_categories() ?
Ok! Good suggestion. I guess my mistake was copying the code directly from the PHP file in the theme editor. The page source actually lists the categories.

The category drop-down menu now appears. So at least that part of the problem seems to be solved.

Now, the uploader isn't creating the post. That's one of the things its' supposed to do.

Here is my revised code with the categorys inserted.

Any idea why the post isn't being created?

Code: Select all


<?php
            $current_user = wp_get_current_user();
            ?>
            <div id="postbox">
            <form id="new_thread" name="new_thread" method="post" action="" enctype="multipart/form-data">      
                        <label for="comment">Video Title</label>
            <input type="text" id="author" value="" name="video_title" placeholder="Video Title" />
                        <br/>   
                        <label for="comment">Post Description</label>
            <textarea id="comment" name="video_description"></textarea>
                        <br />
                        
                <div class="video-options">
                                <input type="radio" name="video_options" value="video_custom" class="video-custom" />
                                <label for="comment">Video Uploader</label>
                        </div>  
                                                
                        <div class="video-custom vid-option">
                                <label for="comment">Video Uploads Only</label>
                                <br/>
                                <input type="file" name="upload_attachment[]" id="user-image-featured" size="20">
                                <p>
                                <br/>
                        </div>
 
                        <?php
                        <div class="video-cat">
				<label for="comment">Video Categories</label><br/>
				<select name='cat' id='cat' class='postform'  tabindex="4">
	<option value='-1'>Category</option>
	<option class="level-0" value="3">Animation</option>
	<option class="level-0" value="6">Kids</option>
	<option class="level-0" value="11">Sports</option>
	<option class="level-0" value="97">Drama</option>
	<option class="level-0" value="103">Food</option>
	<option class="level-0" value="104">Fashion</option>
	<option class="level-0" value="107">Comedy</option>
	<option class="level-0" value="108">Sci-Fi</option>
	<option class="level-0" value="133">Web Series</option>
	<option class="level-0" value="134">Gaming</option>
	<option class="level-0" value="136">Drama Pilots</option>
	<option class="level-0" value="137">Comedy Pilots</option>
	<option class="level-0" value="138">Sci Fi Pilots</option>
	<option class="level-0" value="140">Animation Pilots</option>
	<option class="level-0" value="142">Kids Shows Pilots</option>
	<option class="level-0" value="148">Watch Now</option>
</select>
			</div>
                        
            <!-- Submit button-->
            <br />
            <input type="submit" value="Save Post" tabindex="5" id="thread_submit" name="thread_submit" class="thread-button" />

            <input type="hidden" name="insert_post" value="post" />

            <?php wp_nonce_field( 'new_thread' ); ?>

            </form>

            </div>

User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Video Uploader Form does not work properly

Post by Christopher »

Maybe:

Code: Select all

action=""
(#10850)
steveryan
Forum Newbie
Posts: 13
Joined: Wed Aug 05, 2015 5:19 pm

Re: Video Uploader Form does not work properly

Post by steveryan »

Christopher wrote:Maybe:

Code: Select all

action=""
Makes sense, but that's exactly how it's written in source view. Could it be there is a class being called that is cannot find?

I left out this line....

Code: Select all

<div class="new-post" style="display:none">
Post Reply