I am trying to build a website that will allow users to post from the front end. I need to be able to have the user enter a title, a category, and tags. For the content of the post, I would ideally have the WordPress TinyMCE from the backend on this page, with the add media button included. I have stripped out the features of the TinyMCE that I don't want users to have access to, such as justify text, h1, indent, outdent, etc. I use jetpack to allow for oEmbeds, but I want to just give users instructions for how to use the form and let them handle it. They can have the text, images, and embedded video/audio arranged in whatever order they like if they are submitting content through a TinyMCE. It's kind of like what Kickstarter has for submitting a project.

With that said, I can add a TinyMCE to a page, using the following PHP in my page template:

    wp_editor($mytext_var,"mytext", array('textarea_rows'=>12, 'editor_class'=>'mytext_class'));

I can control what appears in theTinyMCE's toolbar with this code in my functions template:

// TinyMCE: First line toolbar customizations
if( !function_exists('base_extended_editor_mce_buttons') ){
    function base_extended_editor_mce_buttons($buttons) {
        // The settings are returned in this array. Customize to suite your needs.
        return array(
        'formatselect', 'bold', 'italic', 'sub', 'sup'
    /* WordPress Default
    return array(
        'bold', 'italic', 'strikethrough', 'separator', 
        'bullist', 'numlist', 'blockquote', 'separator', 
        'justifyleft', 'justifycenter', 'justifyright', 'separator', 
        'link', 'unlink', 'wp_more', 'separator', 
        'spellchecker', 'fullscreen', 'wp_adv'
    ); */
add_filter("mce_buttons", "base_extended_editor_mce_buttons", 0);

// TinyMCE: Second line toolbar customizations
if( !function_exists('base_extended_editor_mce_buttons_2') ){
function base_extended_editor_mce_buttons_2($buttons) {
    // The settings are returned in this array. Customize to suite your needs. An empty array is used here because I remove the second row of icons.
    return array(
        'bullist', 'numlist', 'link', 'unlink', 'blockquote', 'removeformat', 'undo', 'redo'
    /* WordPress Default
    return array(
        'formatselect', 'underline', 'justifyfull', 'forecolor', 'separator', 
        'pastetext', 'pasteword', 'removeformat', 'separator', 
        'media', 'charmap', 'separator', 
        'outdent', 'indent', 'separator', 
        'undo', 'redo', 'wp_help'
    ); */
add_filter("mce_buttons_2", "base_extended_editor_mce_buttons_2", 0);

// Customize the format dropdown items
if( !function_exists('base_custom_mce_format') ){
function base_custom_mce_format($init) {
    // Add block format elements you want to show in dropdown
    $init['theme_advanced_blockformats'] = 'p,h3';
    // Add elements not included in standard tinyMCE dropdown p,h1,h2,h3,h4,h5,h6
    //$init['extended_valid_elements'] = 'code[*]';
    return $init;
add_filter('tiny_mce_before_init', 'base_custom_mce_format' );

My problem is that I don't know how to make a form that will allow me to incorporate the TinyMCE into a form that will generate a post on my site that is posted under a custom post type when the user clicks the Submit button. I know how to make HTML forms, but I don't know how to make PHP forms, nor do I know how to make the TinyMCE take its raw HTML output and post that to the PHP form.

If anyone can help me, I'd greatly appreciate it.

and for those who desire, use the code snippets on client sites of your own you have any need to limit what the TinyMCE will allow you to do. I use that for clients all the time so that they can't do something like throw crazy rainbow colored paragraphs into the mix, or mess up their own SEO by using an H1 tag.

  • For what it's worth, I believe Gravity Forms has add-ons that can handle your requirements.
    – vancoder
    Apr 24, 2013 at 23:03
  • The only issue with gravity forms is that I can't get it to keep the add media button when I use the Gravity Forms + WYSIWYG plugin, and I can't get GF to allow multiple file uploads. If either of those two can be accomplished then GF is the way to go. I like it, I'm just being a little picky, but it is all for good reason. Apr 24, 2013 at 23:08


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.