I am working on a WordPress project where my client has guest authors allowed to submit posts but are having trouble figuring out the WordPress Admin section and, in particular, how to embed YouTube videos in their posts. I added the wp-user-frontend plug-in which allows posts from WordPress’ front end. I added a custom field to the form and I am trying to intercept the submission of the form to concatenate the two values before the form submits.
I can alert the value of the textbox and the value of the textarea but when I try the concatenation, nothing happens.
Any help is greatly appreciated on the jQuery code below:
<script type="text/javascript">
(function($){
$('#wpuf_new_post_form').submit( function(){
var value = $('#new-post-desc_ifr').contents().find('#tinymce').html();
var tube = $('#cf_YouTube').val();
var new_val = '';
if( $.trim(tube).length) {
new_val += value;
new_val += '<br><iframe width="560" height="315" src="http://www.youtube.com/embed/';
new_val += tube;
new_val += '" frameborder="0" allowfullscreen></iframe>';
$('#new-post-desc').val( new_val );
} // end if
return true;
});
})(jQuery); // END self-invoking anonymous function
/*************************************************/
</script>
I edited the code to eliminate my STUPID error and now the form posts but it still posts the contents of the textarea and ignores the video code. Any ideas on what else is wrong beside the dumb php error???
it’s
+=
to concentenate in Javascript, not.=
, that’s in PHP!Nothing happens because
.=
is not a valid javascript operator for string concatenation. That’s php. Use+=
instead.