I threw a little something together today to add WYSIWYG editing to BuddyPress, using TinyMCE. I want to be careful about the tags I allow, so I’m whitelisting, which is a bit tedious. As a result, there are only a few buttons available: a, em, strong, ul, ol, li. It’s a start, though.
Seems to work everywhere in BP: forums, wire, messages, profile pages.
A note about TinyMCE: WP ships with TinyMCE, and I thought it made sense to use that version instead of attaching one to this plugin. I think that the path to TinyMCE (line 20 of the plugin) should work on all installations, but you may have to tinker if you don’t see it popping up in the head of your BP pages. Moreover, the language files for WP’s version of TinyMCE are misnamed, which means that they don’t work right out of the box (at least for me they don’t). You may need to change the name of wp-includes/js/tinymce/langs/wp-langs-en.php to en.php in order to get the hover and help text in the TinyMCE box to work.
Download the plugin here. Don’t use in a production environment unless you are very certain that you are satisfied with the security of this plugin!
Some members of the still-young CUNY Academic Commons, eager to start groups in support of various projects, have been getting hung up on the process of putting a group together: first, each person has to sign up for the Commons; second, each person has to become friends with the group admin; third, each person has to request membership or wait to be invited (in the case of private groups). I just released a plugin called Invite Anyone that cuts out the second step: with the plugin activated, group admins can invite anyone from the installation, not just friends.
Read more about it, and download the plugin, at the CUNY Academic Commons Dev blog.
EDIT: Please leave further comments or questions regarding this plugin at its permanent home: Invite Anyone
Cross-posted at the CUNY Academic Commons Dev Blog
Rodney Blevins and Marius Ooms wrote a fantastic plugin for BuddyPress called Groupblog, which allows BP groups to easily create a blog associated with their group. The killer feature of the plugin is the ability to add all group members to the blog (as authors, editors, subscribers, whatever you’d like) in a more or less automatic fashion – a far, far easier task than adding users manually through Dashboard > Add User.
I found, though, that the process wasn’t quite as automatic as I’d like. They’d based the code for adding users on a plugin by Burt Adsit called Community Blogs. Community Blogs only triggered the user adding process on a one-by-one basis: members of a group weren’t added to the group’s blog until they visited the blog. This is problematic for a few reasons. First, it’s an added step that creates some confusion among group admins and members, who assume that community blog membership should be automatic. Second, we’ve enabled various levels of privacy for blogs at the CUNY Academic Commons, and group members who were not yet members of a private group blog couldn’t really visit the blog to kick start the process. (Strictly speaking, that’s not true: the add user process was hooked to a process that took place when the blog’s login screen popped up, which happens when you persistently try to visit a blog to which you don’t have access. But this is extremely confusing.)
I took a bit of time today to rework how Groupblog handles the add user process. With the new setup, every member of a group is added to the group blog at once. The process is put into motion when the blog’s administrator updates and saves the group’s Group Blog settings. Other members of the BP community who join the group after the initial blog setup are added automatically to the blog as well, in accordance with the settings that the admin has determined for member permissions.
All the changes I made to the plugin are found in the main plugin file, bp-groupblog.php. You can download the modified file here: bp-groupblog.php.txt (don’t forget to make sure that the file is named bp-groupblog.php to make the plugin work). Just replace the stock version of the file with this one to make the changes. I intentionally did not clean up the plugin – all the original code is deactivated but still present beside the new code – because I wanted users to be able to differentiate what I had written from what the original authors had written (at least for now).
The upgrade from BuddyPress 1.0.x to BuddyPress 1.1 on the CUNY Academic Commons posed a number of challenges. Between the big changes to theme structure, the one-click installation of bbPress forums, and ongoing plugin compatibility issues, a lot of planning and testing was required. This week, I and the rest of the CAC development team finally made the switch. Over the course of a few practice upgrades in development environments, followed by an upgrade on the production site, I developed a pretty detailed set of instructions for myself. I thought I’d write up an annotated version of those instructions, for the benefit of anyone who might be facing a similar upgrade.
The Academic Commons had previously been set up roughly along the same lines as Jim Groom describes here: with bbPress storing its data in a separate database, but through the cunning use of various clever plugins, sharing user data, cookies, and BP group info with the WPMU installation. BP 1.1 does things differently: the one click installation of BP forums expects to store its data in tables that exist in the BP/WP database. In order to save the old data, we had two choices: move the old data into the new structure, or make BP 1.1 recognize the old db setup. Fellow dev team member Chris Stein and I decided that the former choice would be the easiest and most future proof. Here’s how it was done.
Dealing with bbPress forums
- Move orphan forums into groups. Strictly speaking, this doesn’t have to be done first, but if you’ve got bbPress forums that aren’t attached to groups, you’ve got to get them in a group in order for them to display in BP. To the best of my knowledge, there’s no really way to do this from the bbPress or BP admin panels, but it’s easy to do manually. Set up a new group for each forum (a “Help” forum might get a “Help” group, for example), make sure the group has discussion forums enabled, and then find the line in table wp_bp_groups_groupmeta corresponding to the group_id of the new group and meta key `forum_id`, and change the meta_value to match the forum number of the orphan group. Rinse and repeat.
- Export your bbPress database to a local file.
- Replace HTML markup. bbPress (my installation at least) stored formatting in HTML. The most common markup has to do with line breaks: bbPress interprets a single line break in a forum post as <br />, and double line breaks as </p> and <p>. Opening the local version of the bbPress db in a plain text editor, I did a couple big search-and-replaces:
- </p>\n<p> became nrnr (redundant UNIX newlines)
- Some <p> and </p> tags still remain (single paragraph posts), which I replaced with an empty string
- <br /> became nr
You’ll also need to make sure that all references to tables in the SQL dump are replaced with the proper names. For me, that meant replacing things like bb_posts with wp_bb_posts, but it might be different depending on the prefixes you use for bbPress and WP. If you’re not sure about how BP will name the tables, do the one-button forum setup in BP 1.1 (as a new installation) and post a test forum item, to make sure the forums get created. Then check out the database to see how BP formats table names on your install.
The instructions at buddypress.org are quite helpful. Here’s a short version:
- Deactivate BP-dependent plugins. I once neglected to do this. If you do, and then deactivate BP, there is a very good chance that your entire site will go white-screen-of-death, as the plugins will be making reference to BP functions that do not exist. Check your plugin list three or four times to make sure you’ve deactivated each one that has to do with BuddyPress. I like to make a list, so that I remember which ones to activate after the upgrade (though some, like the bbPress integration plugins, won’t be necessary).
- Back up all your data. Always! I like to take a snapshot of the whole database, and then an individual export of the wp_sitemeta table. That way, if I screw anything up (say, by deactivating plugins in the wrong order!) I can bring the site back to life by reverting to a previous state that is known to work.
- Upgrade BuddyPress. Deactivate, upload, reactivate.
- Reactivate BP dependent plugins. I didn’t have too many issues with plugin compatibility, but you might, depending on what you use. Some plugins will not be necessary anymore, while others (like Forum Attachments for BuddyPress) become useful.
The CUNY Academic Commons was in the midst of a redesign, so it made sense to have the new design implemented in BuddyPress’s new, parent-child theme environment. Buddypress.org has some instructions that you might find helpful. Our theme consists of a highly customized home page, header, and footer, with interior BuddyPress pages that are more or less similar in terms of markup to the BuddyPress parent theme. Thus it made sense for us to create a child theme in wp-content/themes (by copying and renaming the bp-default folder that comes with BuddyPress), make our CSS changes, and fill our child theme with only those templates where our markup had to differ from bp-sn-parent. For us that means home.php, header.php, footer.php, functions.php (which does not override but adds to bp-sn-parent/functions.php), and a few other miscellaneous files. How to implement:
- Rename bp-themes. If BuddyPress sees the bp-themes folder, it will assume that you’re going to use the older, deprecated theme structure. I renamed it to bp-themes-old, and will remove it altogether once we’re 100% done with the migration.
- Move bp-sn-parent, bp-default, and your child theme to the main WP themes folder. In most cases this is wp-content/themes.
- Activate the themes in Dashboard > Site Admin > Themes. No need to activate bp-sn-parent, since it’s not used directly.
- Apply the child theme of your choice (either bp-default or your custom theme) to the main blog.
Setting up the forums
You’ve exported and modified the forum data from the bbPress standalone version, but you’ll still need to get them into BP.
- Rename /forums. In our case, our previous installation of bbPress just happened to live at [BP install dir]/forums – exactly where the BP 1.1 forum directory goes. I don’t think it’d hurt anything to leave that folder named the way it is (because of the order in which BP handles URL arguments), but just to be safe I changed it to forums-old.
- Set up BP forums. In Dashboard > BuddyPress > Forum Setup, set up forums as a new installation.
- Drop the empty forum tables from the BP database. I can’t remember whether BP creates the forum tables upon installation or upon the first forum post, but in any case you won’t be able to import your old data properly without first dropping any table prefixed with wp_bb_.
- Import the modified local version of your forum data. I did it in PHPMyAdmin, which was easy because the file had been exported in the form of a huge INSERT command. If all goes well – and it should! – you should now be able to navigate to your groups and see the proper forum posts for that group.
There are kinks we’re still trying to work out of the system. Some strange things happened to some users’ avatars after the upgrade. And tweaking the theme is turning out to be a hassle in a lot of ways. But overall, the migration of data – which I had lost a bit of sleep over – went extremely smoothly. Good luck!
I posted about this a while ago, but I have ported _ck_’s bb_attachments plugin to BP 1.1.x. I took some time today to clean up the readme files and submit the plugin to the wordpress.com plugin database. Nothing about the plugin itself, or the hooks you’ll have to put into your theme, has changed since my last post; but at least now you’ll receive the file with full documentation and can use the WP plugin installer to install and maintain this bad boy.
Get it here or by searching for “forum attachments” on WP’s Add New Plugin page.
Bug reports (and especially patches!) are welcome.
Now that bbPress is integrated into the Very Fabric of BuddyPress, there’s some demand for useful bbPress plugins to be ported over to BP. One of the most useful is _ck_’s excellent bb-attachments, which allows users to add attachments to their forum posts. I have spent a bit of time in the last few days porting it over to BP. If anyone out there is running a BP+bbPress setup (I think it should work in any recent version of BP, but I’ve only tested in BP 1.1) and would like to help me to test what is I think a functional BP version of the plugin, please do so. Here are the details.
- Download the plugin bb-attachments.php.zip
- Unzip and upload to your WPMU plugin directory. Activate it.
- You’ll have to make a few changes/additions to your theme files to make it work. In your BP theme directory, go to groups/single/forum/topic.php. On line 9, after the ‘template_notices’ hook, add
Next: After line 61, which reads
insert the following line
Next: On line 26, replace
<form action="" method="post" id="forum-topic-form" class="standard-form">
<form action="" method="post" id="forum-topic-form" class="standard-form" enctype="multipart/form-data">
- In the same theme directory, open edit.php and index.php. Find the <form> tags, as described in the last part of the previous step, and replace them with the alternative <form> tag (with the enctype specified)
- Follow steps 1 and 2 from here. Step 5 on that page (the “optional settings”) you can do as well, and those settings might take some tweaking for certain filetypes to be allowed.
- Start uploading!
A few caveats:
- I have not tested any of the AWS abilities. It’s possible that they will still work, as the AWS functionality is more or less abstracted from the specific bbPress hooks.
- Inline images are not yet supported. I’m working on it.
- Things look a little bit ugly with the default BP 1.1 theme. I haven’t done much to make it pretty. I’m happy to take aesthetic suggestions, if you have any.
Thanks in advance for your help. Please leave any comments here in this post’s thread.
I made the changes necessary to make Group Forum Subscription work with BuddyPress 1.1. Let me know if you find any broken parts.
BuddyPress and bbPress can be plugged into each other such that BuddyPress groups get their own discussion forums, which are powered by bbPress. Adding Burt Adsit’s bpGroups means that private and hidden groups can have their discussion forums private too. But a major hurdle is email notification: Certain kinds of BP communities simply won’t get rolling if there’s no easy way for users to get email notification of new discussions. There are solutions out there to assuage this problem within bbPress (notably Thomas Klaiber’s Post Notification, which served as the inspiration for the mechanics of my own plugin), but email notification remains hidden in bbPress favorites, instead of in an out-front toggle.
Group forum notification is coming in a future version of BuddyPress, but it’s important enough that I needed it now.
This set of plugins, called Group Forum Subscription, fixes that. Features:
- Users can subscribe to individual discussion topics from within BuddyPress
- Users can subscribe to topics on a group-by-group basis – that is, one can subscribe to all existing and future topics associated with a particular BuddyPress group
- Users are automatically unsubscribed from a group’s discussions when they leave the group
- Administrators can subscribe all users to the appropriate forums with a single click (potentially handy for first-time setup
- Administrators can toggle whether email notification is turned on by default.
- Administrators can determine whether the topic links in the notification emails will point to bbPress or to the BuddyPress forum interface
- Download the package
- Upload the BuddyPress plugin bp-group-forum-subscription.php to the plugins directory of your main WPMU blog and activate it
- If you prefer for the members of your community to use the BuddyPress posting interface for discussions, add the following hook:
in /[your bp theme dir]/groups/forums/topic.php
- If you plan for your users to use bbPress for forum reading and posting, upload the bbPress trigger plugin bb-group-forum-subscription.php to [bbpress-install-dir]/my-plugins/ and activate it through the bbPress admin screen. Please note: the bbPress plugin changes the (IMO somewhat opaque) “Add to favorites” link on each topic page to a more straightforward Subscribe/Unsubscribe. If you like this change, open up [bbPress-theme-dir]/topic.php, and change
user_favorites_link( array('mid' => __('Subscribe to this discussion')),array('mid' => __('Unsubscribe from this discussion')));
You can configure the plugin on the admin page (Group Forum Subscription under Dashboard Settings. Members of your BP community can tinker with their subscriptions either on the individual topic pages (in bp or bbpress) or on their BP Settings > Notification page (where they can subscribe/unsubscribe to entire groups).
I’m in the process of setting up BuddyPress 1.1, which was just released today. Once I’ve got a dev instance of it up and running, I will do the necessary fixes to make the plugin run on the new version. (I don’t think it will be too hard, given the number of craptastic workarounds I had to do in this version because of the absence of all the nice 1.1 hooks.) Stay tuned.
If you are interested in the Sitewide Tag Suggestion plugin that I blogged about a few weeks ago, you might like to know that I have finally found some time to write up some proper instructions and implement the changes on the CUNY Academic Commons. If you’re interested, you can download the bugger from the Commons dev blog, and let me know what you think.
Upgrading the CUNY Academic Commons from WPMU 2.7.somethingorother to 2.8.4 went quite smoothly overall. A big problem cropped up a few days after the upgrade, though: integration with bbPress (version 1.0 alpha 6) wasn’t working right. Shared user tables still worked fine, but sessions weren’t carrying over between the platforms – and, worse yet, you had to flush your cookies to be able to log into the other system at all.
A bunch of Googling turned up people with similar problems, but no real solutions (other than the standard setup procedures, such as making sure that the auth_salt etc matched in wp-config.php and bb-config.php). Then I found this thread, where a few people who are smarter than I am had a conversation about WP2.8’s new method for handling cookies. So I understood the problem a little better. Then someone near the end of the thread suggested upgrading bbPress. I did – to bbPress 1.0.2 – and the integration instantly worked perfectly. You don’t even need a plugin on the WP side for it to work anymore.
The moral of the story: The devs at bbPress are awesome. Also, upgrade to bbPress 1.0.2 if you can.