WPMu Development for Education

Making WPMU work in education, one hack at a time

Archive for the 'plugin' Category

New BuddyPress plugin: BP Group Management

Posted by Boone Gorges on 8th March 2010

BuddyPress has great group administrator functions – the ability to invite members to groups, to promote them to different statuses, the ability to ban certain member, and so on. But unless the sitewide administrator is also the administrator of the group, the site admin does not have the same abilities. On some sites – like here on the Academic Commons, where it’s frequently desirable to add members manually to groups – this limitation for sitewide admins can be somewhat restricting.

This plugin, BP Group Management, creates a new administration panel to the Dashboard, accessible only by the sitewide administrator, which does the following:

  • provides a sortable list of all groups (public, private, and hidden) with their created-on dates and ID numbers
  • allows admins to delete groups easily
  • allows admins to view lists of current members, and to promote/demote/ban them
  • allows admins to add any member of the site directly to the group, skipping the need for invitations

Download the plugin here.

The version of the plugin in the repository only works for versions of BuddyPress 1.2 and greater. For a mostly functional version of the plugin that works with BP 1.1.3 (no guarantees on any other versions, but it should work down to BP 1.1 at least), click here.

Posted in BuddyPress, Plugins and Extensions, WordPress, group, management, members, plugin, wpmu | Comments Off

New BuddyPress plugin: BP Group Management

Posted by Boone Gorges on 4th March 2010

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.

Related posts:

  1. New BuddyPress / bbPress plugin: Group Forum Subscription
  2. New BuddyPress plugin: Invite Anyone
  3. Streamlining Group Blogs

Posted in BuddyPress, WordPress, dev.wpmued, edtech, groups, management, plugin, wpmu | Comments Off

A follow-up on use of WordPress Surveys plugin

Posted by Randy on 3rd March 2010

I wrote early last month on an employee workplace feedback tool we launched using our WordPress MU installation and the Survey plug-in.  Overall the plugin worked well.  Here is a screen shot of one of our forms:

The main issue was a problem in the table that holds the responses.  The field that stores the user answer is limited to 255 characters, but no limit is enforced on the form.  And when users are invited to submit free form comments they quickly exceed the 255 limit.  The result is that a number of the responses were cut off in the database, and some of the user response was lost.  Not the nicest thing to realize after the fact, but luckily the fix is easy.

To make the alteration change open the plugin’s surveys.php  file and find the create table section.  Right around line 101 you’ll see the code that creates the surveys_result_answer table.  Alter the ‘user_answer’ column to use the blob data type — you’ll see it is set to a text(255) type, which is too short for many users.

CREATE TABLE {$wpdb->prefix}surveys_result_answer ((
`ID` int(11) unsigned NOT NULL auto_increment,
`result_ID` int(11) unsigned NOT NULL,
`answer_ID` int(11) unsigned NOT NULL,
`question_ID` int(11) unsigned NOT NULL,
`user_answer` blob NOT NULL,
PRIMARY KEY  (`ID`),
KEY `question_ID` (`question_ID`),
KEY `answer_ID` (`answer_ID`),
KEY `result_ID` (`result_ID`)
) ;

This small change fixes that problem.  The only other note is we used this tool on a members-only site.  I’d want to give it a thorough security check before using this on a public site.  I did note the user-text was escaped, so it looks like some protections are in place.  But these days you can never be too security conscious.

Surveys < Plugins < WordPress < Tools < Bin-Co

Surveys WordPress plugin lets you add surveys to your blog. You can let the visitors take surveys and see the result from the admin side. The user who take the survey can enter their details at the end of the survey – or leave it as an anonymous result.

Related Posts

Posted in Data, PHP, Plug-in, Technology, WordPress, blog, content, plugin, plugins | Comments Off

New BuddyPress plugin: BP MPO Activity Filter

Posted by Boone Gorges on 9th February 2010

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.

Related posts:

  1. Removing previous comment edits from BuddyPress activity – a plugin
  2. New BuddyPress plugin: BP Import Blog Activity
  3. New BuddyPress plugin: Enhanced BuddyPress Widgets

Posted in BuddyPress, WordPress, activity, dev.wpmued, edtech, filter, more privacy options, plugin, privacy, wpmu | Comments Off

WP – collecting user feedback

Posted by Randy on 8th February 2010

Just yesterday I had a request to create a tool to collect some follow-up responses from our staff regarding a recent university-wide workplace survey.   So we need something simple, easy to maintain, quick to launch AND that collects the responses in a format that permits easy and flexible reporting.  As I recently demonstrated our WordPress MU installation makes it easy to launch a project-specific site which includes user-login tied to the school’s central user authentication system.  So simple-easy-quick — doing this through WordPress gets me at least half-way there.  And I remembered a recent suggestion in my Twitter feed to look at the WordPress Surveys plugin.

The plugin is pretty simple and written clearly enough to make adjustments easy.  And most importantly it utilizes a table structure that is normalized, and well structured, which will work well for the eventual reporting needs.  I did do some hacking around in the code to change some of the default behavior — mostly just commenting out features we didn’t want.  These would lend themselves well to some additional options in the plug-in settings — maybe I’ll get around to adding those in at some point.  When it comes to the reports I’ll also go into the background, using PHPMyAdmin to grab the tables directly — again it wouldn’t take much to add more flexibility into the WordPress admin panel options for the plug-in, but I’m still running in the quick/simple mode here.  And with the help of the Plaintxt theme it is up and running.

The plugin could be quite useful for all sorts of user feedback on a site, not just surveys.  The nicely structured data collected in plugin-specific tables would make reporting really flexible.

WordPress › Surveys « WordPress Plugins

The Surveys WordPress plugin lets you add surveys to you blog. You can let the vistors take surveys and see the result from the admin side.

Related Posts

Posted in Data, PHP, PLE, Plug-in, Technology, Twitter, WordPress, blog, database, hacking, plugin, plugins, project | Comments Off

New BuddyPress plugin: BP Include Non-Member Comments

Posted by Boone Gorges on 7th February 2010

By default, BuddyPress does not include comments from non-members (or non-logged-in users more generally) in the sitewide activity stream. For some communities, this default behavior is probably just fine. But in a community like the CUNY Academic Commons, which aims to attract readership and conversation from all sorts of folks, whether or not they’re signed in, the sitewide activity stream will be much more meaningful if it includes comments from everyone.

My new plugin, BP Include Non-Member Comments, was built with this purpose in mind. The plugin is activated here on the CUNY Academic Commons, so that all comments on your blog – whether from logged-in users or not – will show up on the news feed.

BP Include Non-Member Comments

The plugin has been tested on version 1.1.3 of BP, as well as the 1.2 release candidate. If you want to use the plugin for 1.1.3 or lower, you will need to uncomment the first few add_action and add_filter lines in the plugin file.

Technical caveat: Non-logged-in commenters have BP user_id 0. When BP creates the activity stream, it decides whether or not to show the Delete button by checking to see whether the user_id for the currently logged in user is the same as the user_id of the person to whom the comment belongs. Presumably, though, you don’t want non-logged-in viewers of the activity stream to be able to delete items from the activity stream at all. BP’s core code is not currently set up to make it easy to remove these buttons, so I employed an ugly fix. If you have changed your theme significantly from the default, you might have to adjust the filter bp_nonmember_comment_content (near the end of the plugin) to remove the button properly.

Download the plugin here.

Posted in BuddyPress, Uncategorized, WordPress, activity, comments, plugin, wpmu | Comments Off

New BuddyPress plugin: BP Include Non-Member Comments

Posted by Boone Gorges on 7th February 2010

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.

Related posts:

  1. New BuddyPress plugin: BP MPO Activity Filter
  2. Removing previous comment edits from BuddyPress activity – a plugin
  3. New BuddyPress plugin: BP Import Blog Activity

Posted in BuddyPress, WordPress, activity, comments, dev.wpmued, edtech, plugin | Comments Off

Class blogrolls: No sweat

Posted by Boone Gorges on 25th January 2010

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
    $link_cats = get_terms( 'link_category');

    Replace it with

    $link_cats = get_terms( 'link_category', 'hide_empty=0');

    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.

Instructors

  • 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.

Students

  • 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.

Related posts:

  1. New WPMU plugin: Shared Blogroll
  2. Blog-specific email plugin for WPMU users
  3. Streamlining Group Blogs

Posted in Blogroll, WordPress, dev.wpmued, edtech, links, olt-ubc, plugin, wpmu | Comments Off

Moving from Multi-DB to SharDB on WPMu

Posted by Reverend on 24th January 2010

In the early morning hours yesterday we moved UMW Blogs from multi-db (which is a multi-database setup provided through WPMuDev Premium at a cost) to the ever so free SharDB multi-db setup, and I’m happy to say it worked. We’ve had some “unscheduled downtime” recently at UMW Blogs, and between the ever-growing traffic and a syndication/tags blog that’s all too full with 99,000 posts—it was high time to start cleaning database house. This post will take you through the switch from multi-db to SharDB, which is surprisingly simple. And the following post will be about optimizing a multiple database setup that depends heavily on syndication like UMW Blogs does.

Multi-DB –> SharDB
So, our first step was to move to Ron Rennick’s (of wpmututotials and @wpmuguru fame) SharDB setup because UMW is no longer a subscriber of WPMuDEV Premium, and given upgrades to multi-db are no longer available to us—-we were eager to be rid of it. What’s more, I’m hoping this move to SharDB (accompanied by the database optimization and tags blog clean up) will bring UMW Blogs back to a snappiness we haven’t known for a couple of months now. So here’s to hoping….

When I downloaded SharDB I expected a lot more work than there actually was. The move is rather simple, and save a hiccup or two on my end, it went smooth as silk. The first thing to do is configure the db-settings.php file. UMW Blogs is running on 16 databases (well actually 18, but that is besides the point) on one dedicated server, we don’t have several servers or multiple data centers so I think our setup was rather simple. And while we probably should consider getting another server or two some time soon, as Joss Winn suggested, for right now we’re easy.

[What follows is pretty ugly :) ]

The UMW Blogs db-settings.php configs look like this:
// If you have multiple datacenters you can come up with your own datacenter
// detection logic (php_uname?). This helps ensure the web servers try to
// connect to the nearest database servers first, then distant ones.
define( 'DATACENTER', '' );

function add_slave($read, $host, $lhost = '', $user = DB_USER, $password = DB_PASSWORD) {
global $slaves;
$slaves[] = compact('read', 'host', 'lhost', 'name', 'user', 'password');
}

/* Add your configuration here */

//Use this configuration for a hexidecimal based hash

//Ex. you have 256 databases that follow the naming convention acct_wpmuXX
//where XX is the hexidecimal hash for the blog DB

// how many characters of hexidecimal hash
$shardb_hash_length = 1;
// what is the prefix of your blog database shards (everything before the hexidecimal hash)
$shardb_prefix = 'umwblogs_wpmu_';
// set a string to be used as an internal identifier for the dataset
$shardb_dataset = 'umwblogs';
// do you want to put your primary blog (blog_id 1) in its own 'home' database?
//$enable_home_db = true;
// how many, if any, VIP databases do you have?
$num_vipdbs = 1;
// add this to set the write master read priority (default 1)
//$shardb_master_read = 99;
// add this if all of your databases are on a local server
$shardb_local_db = true;
// use this function to add a read slave host
//add_slave($read_priority, $hostname, $local_hostname, $user, $password);

// instructions for adding vip blogs at the bottom of this confg filei

/* That's all, stop editing! Happy blogging. */

I wasn’t entirely certain about all the details in the config file, so before I did the upgrade I posted a few questions on the WPMu Forums here, and Ron himself bailed me (thanks Ron!). Once I had the db-settings file squared away I uploaded it to the main directory of UMW Blogs. After that, I added two lines to the wp-config.php file:

//SharDB Settings
define(‘WPMU’, ‘1′);
require_once(‘db-settings.php’);

And finally, I uploaded the dp.php file to the wp-content directory, and the shardb-admin.php file to the mu-plugins directory. (Keep in mind I had already deleted the db-config.php and db.php files that were running multi-db setup.)

Once I had everything up, I went to the homepage of UMW Blogs and got this error:

Connected to localhost:3306 but unable to select database ‘umwblogs_umwblogs’ while querying table ‘wp_domain_mapping’ (global_r)Connected to localhost:3306 but unable to select database ‘umwblogs_umwblogs’ while querying table ‘wp_site’ (global_r)Connected to localhost:3306 but unable to select database ‘umwblogs_umwblogs’ while querying table ‘wp_site’ (global_r)Connected to localhost:3306 but unable to select database ‘umwblogs_umwblogs’ while querying table ‘wp_site’ (global_r)Connected to localhost:3306 but unable to select database ‘umwblogs_umwblogs’ while querying table ‘wp_site’ (global_r)Connected to localhost:3306 but unable to select database ‘umwblogs_umwblogs’ while querying table ‘wp_site’ (global_r)No WPMU site defined on this host. If you are the owner of this site, please check Debugging WPMU for further assistance.

Turns out, multi-db does not require you to change the database name in the wp-config for the mutliple databases. so our database settings were still set to the original single database we started UMW Blogs on: umwblogs_umwblogs. Once I figure this out, I changed the db_name setting to point to our global database:
define('DB_NAME', 'umwblogs_wpmu_global');

Now this aneming convention is particualr to our setup, we have our tables named umwblogs_wpmu_global, umwblogs_wpmu_0, umwblogs_wpmu_1, umwblogs_wpmu_2, etc., up through 9, and then a through f. So our database names look like this:

umwblogs_wpmu_global
umwblogs_wpmu_0
umwblogs_wpmu_1
umwblogs_wpmu_2
umwblogs_wpmu_3
umwblogs_wpmu_4
umwblogs_wpmu_5
umwblogs_wpmu_6
umwblogs_wpmu_7
umwblogs_wpmu_8
umwblogs_wpmu_9
umwblogs_wpmu_a
umwblogs_wpmu_b
umwblogs_wpmu_c
umwblogs_wpmu_d
umwblogs_wpmu_e
umwblogs_wpmu_f
umwblogs_wpmu_vip1

Once I changed the db_name setting in wp-config, SharDB seemed to work fine on every other blog but the main blog: umwblogs.org. After a second of panic, I realized that SharDB was looking for the home blog (or Blog ID 1) in the database _wpmu_c, but I had it in the wpmu_vip1 database. Once I exported the tables from the wpmu_vip1 database into the wpmu_c database, everything worked perfectly. Put the question for me remains, why didn’t SharDB pick up the vip1 database? I had it noted in my db-settings file as follows:

// VIP DB's
if ($enable_home_db === true) {
add_vip_blog(1,'vip1'); // home blog
}

Additionally, when I was doing something in the backend, I came across this error:

Connected to localhost:3306 but unable to select database ‘umwblogs_wpmu_global’ while querying table ‘wp_sitemeta’ (global_w)

I can’t for the life of me remember where I was precisely now, but I’m sure I’ll find it again soon. I was wondering if this might have something to do with a number of global tables we added to the db-config.php file for getting BuddyPress to work with multi-db? Not sure here, kind of fishing for some help, but I know with multi-db we had issues adding global tables for BuddyPress to the global database (same goes for the domain mapping plugin table), and one way to ensure those tables were created in the global database was through the following list of code I stole from D’Arcy, and he breaks the whole thing down better than I ever could here. Now I imagine SharDB doesn;t have this issue, but just wanted to get a sense if anyone else playing with the move from MultiDb to SharDB had any ideas.

// Usage: add_global_table(TABLE_NAME)
// EX: add_global_table(’something’);
add_global_table(‘umwblogs_wpmu_global’);
// BuddyPress
add_global_table(‘bp_activity_sitewide’);
add_global_table(‘bp_activity_user_activity’);
add_global_table(‘bp_activity_user_activity_cached’);
add_global_table(‘bp_friends’);
add_global_table(‘bp_groups’);
add_global_table(‘bp_groups_groupmeta’);
add_global_table(‘bp_groups_members’);
add_global_table(‘bp_groups_wire’);
add_global_table(‘bp_messages_messages’);
add_global_table(‘bp_messages_notices’);
add_global_table(‘bp_messages_recipients’);
add_global_table(‘bp_messages_threads’);
add_global_table(‘bp_notifications’);
add_global_table(‘bp_user_blogs’);
add_global_table(‘bp_user_blogs_blogmeta’);
add_global_table(‘bp_user_blogs_comments’);
add_global_table(‘bp_user_blogs_posts’);
add_global_table(‘bp_xprofile_data’);
add_global_table(‘bp_xprofile_fields’);
add_global_table(‘bp_xprofile_groups’);
add_global_table(‘bp_xprofile_wire’);
add_global_table(‘wp_domain_mapping’);

Other than that SharDB is up and running on UMW Blogs, an given it may be one of the most unstable WPMu sites in the world give we have over 100 plugins and 130 themes, it has been solid as a rock thus far, so fine work Ron.. But to make sure we don’t push our luck too much, now it’s time for the database optimization drill, post forthcoming.

Posted in SharDB, UMW Blogs, WordPress, devwpmued, multi, multiple databases, plugin, wordpress multi-user, wpmu, wpmudev, wpmued | Comments Off

Important Links Widget plugin for WordPress

Posted by dnorman on 21st January 2010

In setting up WPMU sites for classes, I often wind up using the Text widget to add a bunch of important links – login, Dashboard, Add Post, Add Page, etc… to each site. Manually. I finally decided to save some time and just write a plugin that provides a generic widget to give the links on any site that uses it.

If you’re not logged in, it provides a link to login:
not logged in

If you are logged in, it gives you some handy links:
logged in

I’ll eventually add a way to customize the widget (display Add Page? display Add Post? something else?) but for now, it’s an easy fire-and-forget widget for the most common links used by people in a course blogging site.

Get your copy over at the WordPress plugin repository: Important Links Widget

Posted in WordPress, general, plugin, widget | Comments Off