Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Wordpress wp_editor not updating textarea $_POST data

I have a custom admin page setup in wordpress and I'm using the wp_editor() function to show a text editor box, but when I submit/POST the form, the text enter into the editor field is blank.

See (abridged) code for example:

<form method="POST" action="<?php echo admin_url('admin.php?page=mypage');?>">
<?php wp_editor('','newtestfield',array('textarea_name'=> 'newtestfield'));?>
<input type="submit" value="GO">
</form>

<?php
if(!empty($_POST)){
print_r($_POST); // At which point "newtestfield" is always empty (does not reflect any text entered into the editor field)
}
?>
like image 999
David B Avatar asked Dec 17 '25 02:12

David B


1 Answers

Turns out I had some javascript on the page, which I had thought was required to get the editor running, actually it was causing my editor not to work properly, here's the jquery code that I had to remove:

        $("#team_history").addClass("mceEditor");
        if ( typeof( tinyMCE ) == "object" && typeof( tinyMCE.execCommand ) == "function" ) {
            tinyMCE.execCommand("mceAddControl", false, "team_history");
        }
like image 147
David B Avatar answered Dec 19 '25 18:12

David B