Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I am working on a BuddyPress plug-in for a client that requires users to be able to add content from the front end - they never see the back end for security reasons. I have the plug-in written and it works perfectly but it is missing one thing: a rich text editor so that users can customize their content (within reason, of course). Until now, I have ignored this request from the client and explained it as not being possible without a lot more work.

Today, however, I upgraded to 3.3 and noticed the new wp_editor tag. I tried some of the examples shown here, but I cannot get any of them to work properly (a bare-bones call produces the editor but the tabs and media buttons don't work, a basic TinyMCE setting array yields nothing [just a plain textarea].) Inspection with Chrome's Developer Tools reveals that some JavaScript files are being included in the admin area that are not included on the front end. What is the best way to include these files and make this thing work? Thanks!

share|improve this question
add comment

4 Answers

note that wp_editor will echo to output, not put it in a variable. If you want to put it in a variable, just do

ob_start();
wp_editor($content, 'textarea_rich', $args);
$html = ob_get_contents();
ob_end_clean();

and you have what you need in $html. You can also see https://plugins.svn.wordpress.org/indypress/tags/1.0/indypress/form_inputs/tinymce.php for a working implementation.

Another issue I noted is some problem is with w3-total cache minifying (actually, I had those issue with wp_tiny_mce, the function used in wp <= 3.2; I have not checked if it is buggy in wp_editor, too)

share|improve this answer
add comment

The following code should work for you. Just make sure that the textarea id is all lower-case and alphanumeric.

$post = get_post( $post_id, 'OBJECT' );
$args = array(
    'wpautop' => true,
    'media_buttons' => true,
    'editor_class' => 'frontend',
    'textarea_rows' => 5,
    'tabindex' => 1
);                      
wp_editor( esc_html( $post->post_content ), 'textareaid2', $args );

You can read the documentation of the wp_editor function in this Codex page.

share|improve this answer
    
Thanks, Jamàl, but that is exactly the code that I tried to use. –  Joseph Dec 21 '11 at 13:20
add comment

add this to your theme's footer just before the closing body tag:

<?php wp_footer(); ?>

all the editor scripts for wp_editor are output in the footer, and if your theme does not have this tag, which calls do_action('wp_footer'); then the editor won't work.

share|improve this answer
    
Thanks Deryk, but out of habit I always make sure that is in the footer of every theme I create. –  Joseph Jan 9 '12 at 16:54
    
oh, that is't too bad. I was struggling with this one for a while, until I noticed the theme i was using did not have a wp_footer() function. once I added that. all the scripts were added to the footer and it worked great. –  Deryk Wenaus Jan 12 '12 at 7:11
add comment

Don't know if you're still working on this but you can try "WP User Frontend" plugin. It does exactly what you want.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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