7 Goodies From Our Secret WPMU Bag of Hacks, Tricks and Tools

7 Goodies From Our Secret WPMU Bag of Hacks, Tricks and Tools

Actually, it’s not so much of a secret bag. This is a collection of gems from the mu.wordpress.org forums and various dark corners of the internet. You could spend a couple hours reading through months of useless and confusing posts to find that rare gem of a hack – or you can continue reading and let me show you what I’ve found from a recent visit to the forums and a WPMU hack spree. ;) What we have here are a couple of invaluable mySQL queries, hacks and some lesser-known plugins that will probably be of use to you and your WPMU blog owners.

Theme Companion Plugin:

This plugin allows you to give users the ability to design their sites without having to edit the original style.css file. After activating this plugin the user is given options in the plugin menu to add CSS that he wants to override the current styles. This is an excellent plugin to use if you want to allow more customization on the the themes you offer in your WPMU installation. Another major benefit is that the user’s customizations will not be overwritten if you upgrade the theme files. There are many plugins of this kind, but this one works well with most themes, is well-maintained and has been verified to work with WP 2.9.1.

Download here: http://wordpress.org/extend/plugins/comicpress-companion/

Re-Direct User to Primary Blog on Login:

This is great because you don’t have to hack the core files. Just save it as a php file and add it the same way you would any other plugin. It doesn’t require activation.

{code type=php}ID,’primary_blog’));
if($_SERVER[‘HTTP_HOST’] != $blog_details->domain){
header( ‘Location: http://’.$blog_details->domain.’/wp-admin/’);
}
}
}

add_action(‘admin_init’, ‘redirect_to_primary_blog’);

?>{/code}

WPMU Theme Usage Info Plugin

Deanna Schneider, WPMU plugin developer and widget wizard, created this one which allows you to view in your dashboard which themes are being used and by whom. This is useful for tailoring the themes you offer on your WPMU installation to the ones your users are favoring.
Download Here: http://deannaschneider.wordpress.com/2009/11/09/wpmu-theme-usage-info-plugin/

Delete Post Revisions in Your Database to Save Space

Log in to phpMyAdmin and select your WPMU database.
Click the “SQL” button. Paste the following code in the SQL command window:

{code type=php}DELETE FROM wp_1_posts WHERE post_type = “revision”{/code}

Replace the 1 with the blog ID’s for which you want to delete revisions and run the query again.

Mass Delete Comments That Have Not Been Approved

Log in to phpMyAdmin and select your WPMU database.
Click the “SQL” button. Paste the following code in the SQL command window:

{code type=php}DELETE from wp_1_comments WHERE comment_approved = ‘0’{/code}

Replace the 1 with the blog ID’s for which you want to mass delete unapproved comments and run the query again.

Display Posts and Comment Count

Add this to the area of your theme where you want the sentence to appear. It will show how many posts and comments have been generated for the specific blog that you are viewing.

{code type=php}get_var(“SELECT COUNT(*) FROM $wpdb->posts WHERE post_status = ‘publish'”);
if (0 < $numposts) $numposts = number_format($numposts); $numcomms = $wpdb->get_var(“SELECT COUNT(*) FROM $wpdb->comments WHERE comment_approved = ‘1’”);
if (0 < $numcomms) $numcomms = number_format($numcomms); echo $numposts.' articles have been published on this site,'; echo " sharing a total of ".$numcomms." comments."; ?>{/code}

Credit for this hack goes to WPMUPremium.com

Find out how many users registered with your WPMU site in 2009

Log in to phpMyAdmin and select your WPMU database.
Click the “SQL” button. Paste the following code in the SQL command window:

{code type=php}SELECT *
FROM `wp_users`
WHERE `user_registered` <= '2009-12-31 23:59:59' AND `user_registered` >= ‘2009-01-01 00:00:00’
LIMIT 0 , 30{/code}