I’m creating a custom plugin. One of the fields in the plugin let’s the user add data.
If I add a textarea
the user has no control over the text. So I would like to add a editor.
I know WordPress offers the wp_editor();
function.
After some Google-ing I found that it is very easy to implement the editor.:
$content="";
$editor_id = 'mycustomeditor';
wp_editor( $content, $editor_id );
This shows a nice editor. The problem is that the content isn’t getting saved.
The editor is a part of a form so I thought I add the save function to the form save function like this:
if( isset( $_POST[ 'mycustomeditor' ] ) ) {update_post_meta( $post_id, 'mycustomeditor', array_map('sanitize_text_field', $_POST[ 'mycustomeditor' ]) );}
However WordPress thinks different about this. It does create the meta_key
in the database but no value.
I hope anyone can see what I’m doing wrong!