Title: Custom Editors
Last modified: August 20, 2016

---

# Custom Editors

 *  [professor99](https://wordpress.org/support/users/professor99/)
 * (@professor99)
 * [13 years, 9 months ago](https://wordpress.org/support/topic/custom-editors/)
 * One thing missing from WP User Frontend is the ability to easily add customerized
   editors without modifying the core files. This would be highly desireable.
 * To make it easy to add customized editors I have modified the file wpuf-add-post.
   php. The Edit Post page code will also have to be modified as well.
 * Here’s the original code for wpuf-add-post.php
 *     ```
       function post_form( $post_type ) {
       .....
         $editor = wpuf_get_option( 'editor_type' );
         if ( $editor == 'full' ) {
           ?>
           <div style="float:left;">
             <?php wp_editor( $description, 'new-post-desc', array('textarea_name' => 'wpuf_post_content', 'editor_class' => 'requiredField', 'teeny' => false, 'textarea_rows' => 8) ); ?>
            </div>
            <?php } else if ( $editor == 'rich' ) { ?>
            <div style="float:left;">
              <?php wp_editor( $description, 'new-post-desc', array('textarea_name' => 'wpuf_post_content', 'editor_class' => 'requiredField', 'teeny' => true, 'textarea_rows' => 8) ); ?>
             </div>
   
             <?php } else { ?>
               <textarea name="wpuf_post_content" class="requiredField" id="new-post-desc" cols="60" rows="8"><?php echo esc_textarea( $description ); ?></textarea>
             <?php } ?>
       .....
       }
       ```
   
 * Here’s the replacement
 *     ```
       function post_form( $post_type ) {
       .....
         $editor = wpuf_get_option( 'editor_type' );
   
         //Filter $editor. Useful for adding custom editors or assigning editors according to users..
         $editor = apply_filters( 'wpuf_editor_type', $editor );
   
         if ( $editor == 'full' ) {
         ?>
           <div style="float:left;">
             <?php wp_editor( $description, 'new-post-desc', array('textarea_name' => 'wpuf_post_content', 'editor_class' => 'requiredField', 'teeny' => false, 'textarea_rows' => 8) ); ?>
           </div>
         <?php } else if ( $editor == 'rich' ) { ?>
           <div style="float:left;">
             <?php wp_editor( $description, 'new-post-desc', array('textarea_name' => 'wpuf_post_content', 'editor_class' => 'requiredField', 'teeny' => true, 'textarea_rows' => 8) ); ?>
           </div>
         <?php } else if ( $editor == 'plain' ) { ?>
           <textarea name="wpuf_post_content" class="requiredField" id="new-post-desc" cols="60" rows="8"><?php echo esc_textarea( $description ); ?></textarea>
         <?php } else {
           //Use custom editor.
           //Two ways to enable.
           //1. wpuf_editor_type filter above.
           //2. showtime_wpuf_options_frontend filter.
           do_action('wpuf_custom_editor', $editor, $description, 'new-post-desc', 'wpuf_post_content');
         }
         ?>
       .....
       }
       ```
   
 * And here’s an example of it’s use.
 * showtime.php
    ============
 *     ```
       //Add custom editor for WP User Frontend
   
       function showtime_wpuf_custom_editor($editor, $description, $editor_id, $textarea_name) {
       	echo '<div>';
   
       	wp_editor(
       		$description,
       		$editor_id,
       		array(
       			'textarea_name' => $textarea_name,
       			'editor_class' => 'requiredField',
       			'teeny' => true,
       			'textarea_rows' => 8,
       			'quicktags' => false,
       			'tinymce' => array(
       				'theme_advanced_statusbar_location' => 'bottom',
       				'theme_advanced_path' => false,
       				'theme_advanced_resizing' => true,
       				'theme_advanced_resize_horizontal' => false,
       				'plugins' => 'inlinepopups,spellchecker,tabfocus,paste,media,fullscreen,wordpress,wpeditimage,wpgallery,wplink,wpdialogs',
       				'paste_text_sticky' => true,
       				'paste_text_sticky_default' => true,
       				'theme_advanced_buttons1' => 'bold,italic,underline,justifyleft,justifycenter,justifyright,justifyfull,bullist,numlist,outdent,indent,blockquote,wp_more,charmap,spellchecker,link,unlink,undo,redo'
       			)
       		)
       	); 
   
       	echo '</div>';
       }
   
       add_action('wpuf_custom_editor', 'showtime_wpuf_custom_editor', 10, 4);
   
       //Add Showtime Custom Basic Editor to WP User FrontEnd options
   
       function showtime_wpuf_options_frontend_map($element) {
       	if ($element['name'] == 'editor_type') {
       			$element['options']['basic'] =  __( 'Rich Text (basic)', 'wpuf');
       	}
   
       	return $element;
       }
   
       function showtime_wpuf_options_frontend($options) {
       	return array_map('showtime_wpuf_options_frontend_map', $options);
       }
   
       add_filter('wpuf_options_frontend', 'showtime_wpuf_options_frontend', 10, 1 );
       ```
   
 * Now all that’s still missing is the ability for users to select their editor 
   preference in their Profile but that’s another story :).
 * Cheers
    The Professor
 * [http://wordpress.org/extend/plugins/wp-user-frontend/](http://wordpress.org/extend/plugins/wp-user-frontend/)

Viewing 4 replies - 1 through 4 (of 4 total)

 *  [gpspake](https://wordpress.org/support/users/gpspake/)
 * (@gpspake)
 * [13 years, 6 months ago](https://wordpress.org/support/topic/custom-editors/#post-3162344)
 * I’m having some trouble with this.
    I want users to be able to click on ‘Upload
   Media’ and insert images in to the post.
 * To get the ‘Add Media’ button to appear on the add-post and edit-post pages, 
   I granted subscribers the ‘upload_files’ capability with the User Role Editor
   Plugin and I enabled ‘Rich Text(Full)’ in the WPUF settings. When a subscriber
   logs in and clicks on the “Add Media’ button, the WordPress media upload interface
   appears. If the subscriber then clicks ‘Select Files,’ browses to media on his
   or her computer, and clicks ‘Open,’ they receive an error message where the picture
   thumbnail would be.
 * It took me a minute to figure out what was happening but I noticed that the button
   at the bottom of the add media interface, instead of saying ‘Insert into Post,’
   says ‘Insert into Page.’
    I went back to User Role Editor and granted subscribers
   three more capabilities: edit_pages, edit_others_pages, and edit_published pages.
   Once these capabilities have been granted, subscribers can upload media and insert
   it directly in to the post.
 * This tells us that, for some reason, the when the add media button is clicked
   on the WPUF add-post or edit-post pages, the WordPress media uploader is associating
   the media with the page itself rather than the post. When the Insert into Page
   button is clicked, thie image is inserted in to the WPUF post description; the
   user can save the post and they have effectively inserted a picture in to the
   post.
 * There are at least a couple of major issues here.
    Obviously, granting subscribers
   these capabilities is not an option as it gives them the ability to edit actual
   pages if they know the page id. Also, because the images are associated with 
   the page itself, they appear below the WPUF form, on the add post and edit post
   pages as ‘WPUF-Attachments’ and are visible to all users.
 * This is proving more difficult to figure out than I expected.
    The solution is
   to make wp_editor’s Add Media Button recognize that the media is being added 
   to the post description and not the page. However, I’m having a hard time figuring
   out where it’s being handled. Where is the ‘page id’ being passed to the media
   uploader, and how can we change it to be the ‘WPUF post ID?’
 * Any ideas would be greatly appreciated.
 *  Plugin Author [Tareq Hasan](https://wordpress.org/support/users/tareq1988/)
 * (@tareq1988)
 * [13 years, 6 months ago](https://wordpress.org/support/topic/custom-editors/#post-3162345)
 * [@gpspake](https://wordpress.org/support/users/gpspake/), image insertion is 
   being solved in the pro version I talked about. There’s a image insert button,
   click -> select image -> uploads -> inserts the image automatically in post content
   area. Cool 😉
 *  [rajun](https://wordpress.org/support/users/rajun/)
 * (@rajun)
 * [13 years, 5 months ago](https://wordpress.org/support/topic/custom-editors/#post-3162346)
 * when pro version will be release?
 *  Plugin Author [Tareq Hasan](https://wordpress.org/support/users/tareq1988/)
 * (@tareq1988)
 * [13 years, 5 months ago](https://wordpress.org/support/topic/custom-editors/#post-3162347)
 * Within a week I hope.

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Custom Editors’ is closed to new replies.

 * ![](https://ps.w.org/wp-user-frontend/assets/icon-256x256.gif?rev=3578622)
 * [User Frontend – Membership, User Registration, User Profile, User Directory & Content Restriction with Frontend Post Submission](https://wordpress.org/plugins/wp-user-frontend/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-user-frontend/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-user-frontend/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-user-frontend/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-user-frontend/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-user-frontend/reviews/)

## Tags

 * [custom](https://wordpress.org/support/topic-tag/custom/)
 * [editor](https://wordpress.org/support/topic-tag/editor/)

 * 4 replies
 * 4 participants
 * Last reply from: [Tareq Hasan](https://wordpress.org/support/users/tareq1988/)
 * Last activity: [13 years, 5 months ago](https://wordpress.org/support/topic/custom-editors/#post-3162347)
 * Status: not resolved