Category Archives: dev.wpmued

Importing Ning users into WP

Today Ning announced that it would be ending its free social networking service. I tweeted something to the effect that this event is a wake-up call: When you use closed-source, third-party hosted solutions for something as valuable as community connections, you are leaving yourself open to the whims and sways of corporate boards. It’s not that Ning is evil or anything – it goes without saying that they need to make a profit – but their priorities are importantly different from those of their users. In the same way that Ning moves from a freemium model to a paid model, Facebook could start selling your crap, Twitter could crash, Tumblr could go out of business, etc.

All this is a good argument to be using software solutions that are more under your control. Like – drumroll – WordPress and BuddyPress.

Enough moralizing. I whipped together a plugin this afternoon called Import From Ning that will allow you to get a CSV export of your Ning community’s member list (the only content that Ning has a handy export feature for, alas) and use it to import members into a WordPress installation.

As of right now, it does not have any BuddyPress-specific functionality. But the data that it does import – display name, username, email address – are enough to populate at least the beginnings of a BuddyPress profile. The next thing to add is the auto-import of certain profile fields. I might try to do this tomorrow. The plugin is based on DDImportUsers – thanks!


  • Download the zip file and unzip into your WP plugins directory
  • Look for the Import from Ning menu under Dashboard > Users (unless you’re running a recent trunk version of BuddyPress, in which case it will be under the BuddyPress menu)
  • Follow the instructions on that page

Download the plugin here.

New BuddyPress plugin: BP Group Management

Another day, another plugin for BuddyPress. In BP < 1.2, it was impossible for site admins to manage group membership in groups where they weren't also the local admin. This is good in a lot of situations, but in some applications of BP it can be a pain – the system administrator needs more power in order to correct problem, wreak havoc, and so on. In BP 1.2+ the situation is better – admins can manage groups more – but it's still not all that easy to see everything in one place. This plugin rectifies the situation by allowing site admins to manage the members of groups across their BP installation from a single screen.

Read more about it.

New BuddyPress plugin: BP MPO Activity Filter

In the past I and others have experienced some problems with the way that More Privacy Options for WPMu interacts with BuddyPress – or, to be more exact, with the way that the two don’t recognize each other. Blogs marked as private via MPO were getting plastered all over the public activity streams. In the past I have suggested some unpleasant but more or less functional core hacks, but now I’ve developed a plugin that does the job in the right way. It’s called … drumroll … BP MPO Activity Filter.

Check it out here.

New BuddyPress plugin: BP Include Non-Member Comments

I wrote a plugin this afternoon that solves a small but potentially annoying limitation of BuddyPress: its inability to show comments from non-members in the sitewide activity stream. In a streak of extreme creativity, I dubbed the plugin “BP Include Non-Member Comments”. Read more about it, and download it for your own use, here.

Class blogrolls: No sweat

Last week, in the post where I announced my new WPMU plugin Shared Blogroll, I briefly mentioned the use case that I had in mind, which was of course education-focused. Yesterday and today I did some more work on the plugin itself (MORE AJAX 4EVA) and some of the supporting players. I thought I’d spell it out a little more so that others could implement what is probably the coolest system for shared blogrolls on earth, or at least on WPMU, which amounts to pretty much the same thing.

The plugins

  • Shared Blogroll. This creates a widget that allows bloggers to embed a link category from any other blog on the system on their own blog.
  • Add Users Sidebar Widget. This plugin is already pretty great, as well it should be seeing as it’s written by good-looking Canadians. I made some edits to the plugin to make it a bit more flexible.
    1. First I removed the RSS box from the Add User widget. For most of my users, it’ll confuse; for all of them, it’ll be redundant, since they’ll all be using Wordpress blogs and thus will have feeds that are very auto-discoverable.
    2. As the plugin stands in the repository, links are automatically put into the blog’s default link category (or, if they’re using FeedWordPress, the FWP link category). For most users, that’s something unhelpful like “Links” or “Uncategorized”. I altered the plugin so that the blog owner can choose which link category the added links will be put into. As I’ll discuss below, I think that this will add a lot of flexibility to the way that the plugins can be used together. You can download the text of my modified version of Add Users Sidebar Widget here: add-link-sidebar-widget.txt. Save as .php before uploading – and make sure that you uninstall previous versions of the plugin before uploading, or you might get whitescreened to death.
  • Optional step. The default WP Links widget is set up so that you can’t select to display an empty category of links. As you’ll see below, I want to have instructors create a new category for their blogrolls, and I figured it’d be pretty confusing if they couldn’t create a sidebar widget corresponding to a link category until at least one student had posted a link (thus populating the category). So I wrote a little plugin that replaces the default Links widget with one that allows you to pick an empty links category. Drop this into mu-plugins: link_widget_allow_empty_cat. Be warned, though, that this plugin deregisters the default Links widget, which might have the effect of removing every links widget on your installation of WPMU. (I haven’t tested it.) For me, it’s OK, because I don’t have any active users yet. As an alternative, you could edit the core of WP (making sure to back up, take note of where you made the edit for future upgrades, blah blah blah) in the following way. In wp-includes/default-widgets.php, line 139 reads [code language=”php”]$link_cats = get_terms( ‘link_category’);[/code] Replace it with [code language=”php”]$link_cats = get_terms( ‘link_category’, ‘hide_empty=0’);[/code] That should leave all of your pre-existing links widgets in place.

The process

The immediate goal of this setup is to allow a class blogroll to be shared effortlessly between members of a class. (Though I can imagine lots of other very cool uses.) Here are the directions I’m going to give to instructors and students on how to leverage these two plugins to make it happen.


  • Create a new Link Category for your class blogroll – let’s say you call it “ENG 110 Blogroll”.
  • Add a Links widget to the sidebar, making sure to select “ENG 110 Blogroll” from the category dropdown.
  • Add an Add Links widget to the sidebar. Again, be sure to select “ENG 110” blogroll as the target category for added links.
  • Give your blog’s ID number to your students and give them the following directions.


  • After creating a blog, visit the professor’s blog and enter your site’s URL into the Add Link sidebar widget.
  • Add a Shared Blogroll widget to your own blog’s sidebar. Enter the professor’s blog ID number as the source blog, select “ENG 110 Blogroll” from the dropdown list, and Save.

I hope that the instructors and students get into this blogroll sharing thing. It distributes what would otherwise be a huge amount of work for the instructor, or *worse yet*, for me.

New WPMU plugin: Shared Blogroll

I just wrote a widget that lets a blog admin pull a link category from any blog on the same WPMU installation. It is pretty much the bomb, and you are going to love using it so much that you may have to take downers in order to get yourself under control.

Check it out.

Side note: I’m going to start creating separate pages (as opposed to posts) for each of my software releases. That way all comments/support regarding a given plugin will be in the same place, with a pretty URL. That’s why I’m turning off comments on this post.

Blog-specific email plugin for WPMU users

A quick WPMU hack that I think will help a lot of people using an installation of WPMU for multiple classes.

The plugin Email Users by Vincent Prat allows blog authors/admins to email users in two different ways: 1) by emailing a group of users (such as those corresponding a particular role on your blog), or 2) by emailing individual users. The problem, though, is that this second option brings up a list of every single user on the installation of WPMU. This can be a bit of a pain for the normal blog user, as teachers or students in a class would probably only want to see a list of those people who are in the class, or on the blog.

Here’s a hack that will make the Email Users plugin show list only the members of the current blog for everyone except for the site admin:

  1. In the main plugin file (email-users.php), find the function mailusers_get_users. It should start around line 404.
  2. Look for the lines of code (414-417 in my version) that define the variable $users in the first conditional clause:
    [code language=”php”]
    $users = $wpdb->get_results(
    “SELECT id, user_email, display_name ”
    . “FROM $wpdb->users ”
    . $additional_sql_filter );
  3. Replace that line with the following code:
    [code language=”php”]
    if ( is_site_admin() ) {
    $users = $wpdb->get_results(
    “SELECT id, user_email, display_name ”
    . “FROM $wpdb->users ”
    . $additional_sql_filter );
    } else {
    $wp_user_search = new WP_User_Search(”, ”, ”);
    $user_list = $wp_user_search->get_results();
    $user_array = join(‘,’, $user_list);
    $users = $wpdb->get_results(
    “SELECT id, user_email, display_name ”
    . “FROM $wpdb->users ”
    . “WHERE id IN ( $user_array ) ” );

Here’s the use case I envision. The instructor for a class places the Add User Sidebar Widget (by my boys at UBC’s OLT!) in the sidebar of his or her blog. As part of the first assignment of the semester, the instructor asks each student to register for an account, and click the “Add Me” button on the instructor’s blog. That will automatically populate the email list above.

File this tip under “who needs Blackboard?”.

TinyMCE in Buddypress

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!

New BuddyPress plugin: Invite Anyone


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