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!
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
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 inwp_editor
, too)The following code should work for you. Just make sure that the
textarea
id is all lower-case and alphanumeric.You can read the documentation of the
wp_editor
function in this Codex page.add this to your theme’s footer just before the closing body tag:
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.Don’t know if you’re still working on this but you can try “WP User Frontend” plugin. It does exactly what you want.