2

I noticed when you typein the user's “biographical info” on the profile, it shows up in one page! Looks really terrible. So:

Is there a way to use tinyMCE or other solution for user “biographical info” without messing with any core file, and without any plugin?

Thanks a lot.

2
  • Not really sure what you're asking here. It shows up all on one page? What exactly is the issue and what exactly are you trying to accomplish? Nov 12, 2011 at 7:31
  • @Kevin Langly thanks for your response. As I mentioned initially, when you typein the user's “biographical info” on the author bio profile (in the admin), It does not save paragraps, etc. - the entire bio shows up in one big paragraph! I am trying to make stops the stripping of html formatting from the description (bio) field. I hope I made it clear. Thanks again.
    – Tara
    Nov 13, 2011 at 1:23

5 Answers 5

3

Not sure if this is the perfect way to do it, but it worked for me by removing the description element using jQuery and then adding editor for the description element.

/*******************************************
* TinyMCE EDITOR "Biographical Info" USER PROFILE
*******************************************/
function biographical_info_tinymce() {
    if ( basename($_SERVER['PHP_SELF']) == 'profile.php' || basename($_SERVER['PHP_SELF']) == 'user-edit.php' && function_exists('wp_tiny_mce') ) {
        echo "<script>jQuery(document).ready(function($){ $('#description').remove();});</script>";
        $settings = array(
            'tinymce' => array(
                'toolbar1' => 'bold,italic,bullist,numlist,link,unlink',
                'toolbar2' => '',
                'toolbar3' => '',
                'toolbar4' => '',
            ),
            'wpautop' => true,
            'media_buttons' => false,
            'quicktags' => false,
        );
        $description = get_user_meta( $user->ID, 'description', true);
        wp_editor( $description, 'description', $settings );
    }
}
add_action('admin_head', 'biographical_info_tinymce');
remove_filter('pre_user_description', 'wp_filter_kses');
add_filter( 'pre_user_description', 'wp_filter_post_kses' );
2
3

Add this to your functions.php:

/*******************************************
* TinyMCE EDITOR "Biographical Info" USER PROFILE
*******************************************/
function biographical_info_tinymce() {
    if ( basename($_SERVER['PHP_SELF']) == 'profile.php' || basename($_SERVER['PHP_SELF']) == 'user-edit.php' && function_exists('wp_tiny_mce') ) {
        wp_admin_css();
        wp_enqueue_script('utils');
        wp_enqueue_script('editor');
        do_action('admin_print_scripts');
        do_action('admin_print_styles-post-php');
        do_action('admin_print_styles');
        remove_all_filters('mce_external_plugins');

        add_filter( 'teeny_mce_before_init',
            create_function( '$a', '
$a["theme"] = "advanced";
$a["skin"] = "wp_theme";
$a["height"] = "300";
$a["width"] = "440";
$a["onpageload"] = "";
$a["mode"] = "exact";
$a["elements"] = "description";
$a["theme_advanced_buttons1"] = "formatselect, forecolor, bold, italic, pastetext, pasteword, bullist, numlist, link, unlink, outdent, indent, charmap, removeformat, spellchecker, fullscreen, wp_adv";
$a["theme_advanced_buttons2"] = "underline, justifyleft, justifycenter, justifyright, justifyfull, forecolor, pastetext, undo, redo, charmap, wp_help";
$a["theme_advanced_blockformats"] = "p,h2,h3,h4,h5,h6";
$a["theme_advanced_disable"] = "strikethrough";
return $a;' )
        );

        wp_tiny_mce( true );
    }
}
add_action('admin_head', 'biographical_info_tinymce');

. Someone is due for credit on this but i can't remember where i have found this..

Anyhow this works great for me

5
  • thanks for youe reponse. TinyMCE shows up above the “biographical info” on the profile. But, how how I make the paragraph break? The text still shows up on the author's page as one long paragraph like before. Thanks again.
    – Tara
    Nov 12, 2011 at 19:05
  • Are you sure you clicked ENTER and not SHIFT + ENTER ??
    – Sagive
    Nov 12, 2011 at 19:14
  • Yee, Went ahead and checked it.. your right... paragraphs are bieng cleand out when saving...
    – Sagive
    Nov 12, 2011 at 19:22
  • thanks for looking into. Appreciate your time and help. Hope somebody can help make this function work.
    – Tara
    Nov 12, 2011 at 20:37
  • 1
    Note that this is probably easier to do with wp_editor now than it was when this answer was written
    – Tom J Nowell
    Nov 2, 2021 at 23:41
2

I’ve written a plugin that replaces the Biographical Info profile field with the WordPress visual editor, TinyMCE, allowing you to editor an author’s biography using rich text using a new function, wp_editor(), that was released with WordPress 3.3.

http://wordpress.org/extend/plugins/visual-biography-editor/

Using this plugin will ensure that the editor isn’t wiped out with the next core update, which you should definitely do for security reasons.

0
1

Just adding this to the theme's functions.php solve the problem (prevent stripping of the html from the author's bio):

remove_filter('pre_user_description', 'wp_filter_kses');  
add_filter( 'pre_user_description', 'wp_filter_post_kses' ); 
0

Just add it

function mysite_show_extra_profile_fields($user) {
    wp_enqueue_editor();

    ?>
    <script>
    document.addEventListener("DOMContentLoaded", function(event) {
        var id = 'description';
    
        wp.editor.initialize(id, {
            tinymce: {
                wpautop: true
            },
            quicktags: true
        });
    });
    </script>
    <?
    }
    
    add_action('show_user_profile', 'mysite_show_extra_profile_fields');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.