Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have a working front end posting system on my site that initially I designed with a simple text area for the content. I am now attempting to swap the textarea out with the TinyMCE function, wp_editor. I can easily get the editor to display and function properly, but on the submission of the form, the content is saved/not saved in a strange way.

The behavior is as follows: When I attempt to publish the post the first time, the content does not seem to save, leaving the textarea blank. If I edit the post and save it again, the OLD content (from the first save) magically reappears and the new stuff is gone. After that, it randomly gives me either nothing or the old content only.

I've looked around, but was only able to find this question: wp_editor textarea value not updating which doesn't exactly apply to my situation and I'm not sure that any of those solutions are really what I need.

I'm not sure what code would be best to help troubleshoot, but here is my original text box:

<textarea name="user_post_content" id="user_post_content" placeholder="Enter your content..." class="inputwide"><?PHP echo ((!empty($post_obj->post_content))?$post_obj->post_content:''); ?></textarea>

And here is what I want to replace it with:

<?php wp_editor($post_obj->post_content, 'userpostcontent', 'textarea_name=user_post_content' ); ?>

Here is a pastebin of the entire page template file: http://pastebin.com/tncmQGDA

Hopefully someone can help.

share|improve this question
    
Still looking for an answer that helps me figure this out. Anyone? –  Eckstein Dec 21 '12 at 4:25
add comment

3 Answers 3

Check with a array for the settings - $settings (array) (optional) An array of arguments. - on the function wp_editor.

wp_editor(
    $post_obj->post_content,
    'userpostcontent',
    array( 'textarea_name' => 'user_post_content' )
)
share|improve this answer
    
Thank you. I made that change, but it still doesn't seem like the field is being saved, or something else weird... I'm using this little validation code to make sure the user has entered content, and with the editor in place, it keeps saying there is nothing there (even when there is). if(empty($_REQUEST['user_post_content'])){ $error_flag = TRUE; $error_msg[]=array( 'key' => 'error_user_post_content', 'value' => __('Please enter some content','tsv'), ); } –  Eckstein Dec 20 '12 at 8:22
add comment

I was working on same kind of project and find this jquery plugin useful

http://jhtmlarea.codeplex.com/

Regards

share|improve this answer
    
Thanks. I want to use TinyMCE though so that the behavior is as close as possible to the admin side, including the media uploader. –  Eckstein Dec 20 '12 at 23:21
add comment

Well, I got it corrected. It looks like it was because my post form uses javascript for errors and confirmation messages. I finally go a hold of the original developer who made this for me and he added this:

   jQuery('#user_post_submit,#user_post_preview,#user_post_savedraft').click(function(){
        var req;
        jQuery('#user_post_content').val(tinyMCE.get('user_post_content_editor').getContent());
        switch(jQuery(this).attr('id')){
            case 'user_post_submit':
                req='publish';
                break;
            case 'user_post_savedraft':
                req='save_draft';
                break;
            case 'user_post_preview':
                req='post_preview';
                break;

        }

Which made this function work correctly:

wp_editor($content, 'user_post_content_editor');

Seems so simply now that it's done....

Thanks for all your suggestions though!

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.