Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Wp_editor Does Not Save Content WordPress

  • REFUNDED

I have a frontend post form on the site I'm developing. The form is at www.theseattlevine.com/new-post). Although, you'll have to register for an account if you want to see it live.

The form is functioning, but when I first built it I just made the content area a textarea. Now I am trying to swap the textarea out for the TinyMCE editor using wp_editor. I can get the editor to display and function properly, but when I submit the form the content of the post is not being saved into the form variables.

This is the area of the template file I'm working with:
<!--<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> -->
<?php wp_editor($post_obj->post_content, 'userpostcontent', array( 'textarea_name' => 'user_post_content' ) ); ?>


Currently, the textarea that I originally had is commented out right above the new wp_editor function.

You can see the code for the whole page here: http://pastebin.com/uHtvHEQf

Hopefully someone can tell me how to make this work!

Thanks.

EDIT:
Thanks for the first suggestion. The reason I stripped the underscores out of the function is because the codex says it only accepts letters: http://codex.wordpress.org/Function_Reference/wp_editor .

Plus, that parameter is the ID of the field, not the name, which is what should actually be passing the value.

EDIT2: Sorry to keep editing the question. The "reply" button doesn't seem to work for me for some reason....

Anyway, I tried both suggestions. I've tried all combinations of underscores and no underscores and also tried putting the array into the $settings variable. It's still not capturing it for some reason.

I am using this bit of code to validate the field:
if(empty($_REQUEST['user_post_content'])){
$error_flag = TRUE;
$error_msg[]=array(
'key' => 'error_user_post_content',
'value' => __('Please enter some content','tsv'),
);
}


Which is what's telling me there is nothing in the content area when I try to submit the form. I've tried submitting the form without validating it, and the form submits and then the content doesn't show up until I save the post a 2nd time.... I don't know, really strange behavior...

Answers (2)

2012-12-21

Arnav Joy answers:

try this

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

instead of

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


Arnav Joy comments:

if you want to remove under scores then try this code

http://pastebin.com/PHSh3cwa

2012-12-21

Jatin Soni answers:

It should work usually.

Try this just to cross confirm either ID doesn't creating any issue.
<?php
$content = $post_obj->post_content;
$settings = array(
' textarea_name' => 'user_post_content',
);

wp_editor($content, 'user_post_content', $settings);

?>