5 Useful Hacks and Code Snippets for BuddyPress and WPMU

5 Useful Hacks and Code Snippets for BuddyPress and WPMU

Hacks- we all need them from time to time. A hack is a way to unleash the power of your WordPress core until such time as your enhancement is added into a new release. What’s the difference between a hack and a plugin you might ask? Not a lot. Plugins make it easier to upgrade your installation without losing your “hacks.” There is a warning in the WordPress codex: “Hacks are not officially supported by WordPress. Use at your own risk. “ In ancient items before WordPress 1.5, hacks were the only way to modify WordPress. Hacks have a bad connotation but there’s nothing wrong with using them to solve an issue that is preventing your install from working the way you want it to. Here are some of our favorites:

Show List of Recently Created Blogs:

Include this snippet in your functions.php file:


/*Fetch an array of $number_blogs most recently created blogs
**@number_blogs :The number of most recently created blogs you want to show.
function get_recent_blogs($number_blogs=5)
  global $wpdb;

/*fetch blog_id,domain,path from wp_blogs table ,where the blog is not spam,deleted or archived order by the date and time of registration */
  $query="select blog_id,domain,path from $blog_table where public='1' and archived='0' and spam='0' and deleted='0' order by registered desc limit 0,$number_blogs";

return $recent_blogs;

Then you can get its output with the following:

<ul class="recent-blogs">

<?php $recent_blogs=get_recent_blogs(5);
	foreach($recent_blogs as $recent_blog):

		if( defined( "VHOST" ) && constant( "VHOST" ) == 'yes' )



<h3><a href="<?php echo $blog_url;?>"> </a></h3>

<span><?php echo $blog_name?></span>
<?php endforeach;?>



Or grab the plugin here. These snippets are courtesy of thinkinginwordpress.com

Hide Selected Profile Feeds:

This hack will hide feeds of profiles that you select in phpmyadmin. It might be helpful if you want to hide the admin user’s actions or some behind-the-scenes moderators, or perhaps a particularly irritating user. ;)

First locate the file:

Then find this:

<?php if ( bp_field_has_data()) : ?>

Change it to read:

<?php if ( bp_field_has_data() && bp_field_has_public_data()) : ?>

Use phpmyadmin and go into the table bp_xprofile_fields and change all the profile field records that are parent fields and have ‘0’ in the column ‘is_public’ to ‘1’ for the fields you want to show on the profile and ‘0’ for the fields you don’t want to show. Parent fields are the ones that have a ‘0’ in the ‘parent_id’ column.
Credits: BuddyPress Forum.

Hide Default BuddyPress Menu:


This is a quick one. BuddyPress gives you options for hiding its menu if the user is not logged in. This little addition to your wpconfig.php file will hide your menu bar, whether the user is logged in or logged out:
define( ‘BP_DISABLE_ADMIN_BAR’, true );

Replace Who’s Online with Recently Active Widget:

membersWhen you’ve got a site with a smaller membership, the “Who’s Online” widget can make your site look a little bit naked. With this quick hack you can make sure that member avatars are there all the time. They will change dynamically based on the users’ recent activity. (It is coupled with the widget below.)

Exploded Groups:

This widget removes the ajax “popular|active|newest” links for the group widget and simply shows three different group displays, one for each: popular, active and newest. Ajax is like candy to me, so I would be hard-pressed to find an instance where this is needed. ;) However, if you want to bring more prominence to these displays, this might be your ticket.

These widgets were developed by the folks over at iqcuties.com. Download these widgets and then replace these files with the ones you downloaded:


Remember that these are hacks, so they will get overwritten when you upgrade. You’ll need to make a list of your hacks if you want to keep that functionality after upgrading. Do you have a favorite hack you’d like to share?