Blogs@Baruch, now with BuddyPress!

I recently completed a significant upgrade to Blogs@Baruch, and I thought I’d blog my hacks and some of the thinking behind them for teh Google to index.

The goal of the upgrade was to get BuddyPress up and running, which will create additional avenues for social publishing and networking around academic interests across the College. The upgrade included two new WordPress child themes, one that uses bp-default (for the home site and all BuddyPress functionality) and one that uses TwentyTen (a new default theme).

if ( is_user_logged_in() )

Since we’re rolling BuddyPress into a system that’s been active for almost two years already, and which has more than four thousand users, I was hesitant to just automatically give everybody public profiles or to make the member list publicly visible. The following simple argument came in very handy in these cases:


<?php if ( is_user_logged_in() ) : ?>
<?php else : ?>
<?php endif; ?>			

I snaked this code through functions in a number of places:

  • in header of the BP child theme to hide the Members list (by excluding the page id for the Members page in the “else” statement)
  • in sidebar.php file of my child theme, to give logged-in users relevant quick links
  • in members/index.php of my child theme, to hide the Members directory
  • in members/single/home.php to hide individual Profile pages

I also hide the BP admin bar for logged out users (which is an option built into BP)… So if you’re a visitor to the site, BuddyPress won’t be visible to you.

Logged out:

Logged in:

This is the way we’re going to keep it for now, and I think such a structure reflects our sense of BuddyPress primarily as a tool for the community to get to know itself a little better. Rumor has it that some more granular privacy control will be coming down the pike in future versions of BuddyPress, and we’ll revisit this issue as appropriate.

bp-custom.php etc.

Every BuddyPress install should have a bp-custom.php file located in wp-content/plugins/ which houses customizations. I used this file to change the order of the tabs on Profile pages, and to insert additional menus on the BuddyPress admin bar.

One of the great challenges I’ve had is the fact that one of my good buddies and partners in pizza-eating crime has become one of the top BuddyPress/WordPress developers around, and Boone’s on my IM rolls. I’m often faced with the dilemma of taking an hour to figure something out, or bothering him and getting some code in about 3 minutes. He helped me with code for the tab order:


function change_profile_tab_order() {
	global $bp;

	$bp->bp_nav['profile']['position'] = 10;
	$bp->bp_nav['activity']['position'] = 20;
	$bp->bp_nav['blogs']['position'] = 30;
	$bp->bp_nav['friends']['position'] = 40;
	$bp->bp_nav['messages']['position'] = 50;
	$bp->bp_nav['groups']['position'] = 60;
	$bp->bp_nav['settings']['position'] = 70;
}

add_action( 'bp_setup_nav', 'change_profile_tab_order', 999 );

The additional menus in the admin bar, I figured out with help from the Codex:


function my_help_link(){
  ?>
  <li><a href="http://blsciblogs.baruch.cuny.edu/support/explanation-of-buddypress/">HELP!</a>

 <ul class="wp-admin-bar">
<li><a href="http://blsciblogs.baruch.cuny.edu/support/guide-to-buddypress/">Guide to Buddypress</a></li>
  <li><a href="http://blsciblogs.baruch.cuny.edu/support/for-blog-authors/">Support for Students</a></li>
  <li><a href="http://blsciblogs.baruch.cuny.edu/support/for-blog-administrators/">Support for Faculty</a></li>
  <li><a href="http://blsciblogs.baruch.cuny.edu/contact/">Contact</a></li>
  </ul>
  </li>
  <?php
}
add_action( 'bp_adminbar_menus', 'my_help_link', 14 );

function quick_links(){
  ?>
  <li><a href="http://blsciblogs.baruch.cuny.edu/support/explanation-of-buddypress/">Quick Links</a>

 <ul class="wp-admin-bar">
  <li><a href="http://blsciblogs.baruch.cuny.edu/about-blogsbaruch/terms-of-service/">Terms of Service</a></li>
  <li><a href="http://www.baruch.cuny.edu/blsci">BLSCI</a></li>
  <li><a href="http://www.baruch.cuny.edu/bctc">BCTC</a></li>
  <li><a href="http://www.baruch.cuny.edu/">Baruch College</a></li>
  </ul>
  </li>
  <?php
}


And, with Boone’s help, I made a change to my wp-config.php file so that Profile (rather than the Activity Stream) became the default component loaded when you visited a member’s page. (I located this line of code just beneath the “/* That’s all, stop editing! Happy blogging. */” comment, as it didn’t work when I put it at the end of the wp-config.php file).


 /** Sets BP Nav to load Profile first */
define( 'BP_DEFAULT_COMPONENT', 'profile' );

These changes are intended to prioritize Profiles. We want our users to share information about themselves and to use Boone’s Custom Profile Filters to connect with others at the College with similar interests. While the CUNY Academic Commons, for which that plugin was written, hopes to connect CUNYs across campuses, we want do this on a more local scale. When all of our incoming students get their Blogs@Baruch accounts next week, they will be asked to fill out their profiles and to begin exploring.

New Default Theme

I also used the upgrade opportunity to create a new default theme for sites created on Blogs@Baruch, a child of TwentyTen which features some Baruch College and CUNY branding/linking and altered css. Aided by this tutorial, I swapped out the built-in header images that ship with TwentyTen for images taken from Baruch College’s library of photographs. Here’s the code for that, placed into the theme’s functions.php file:


define( 'HEADER_IMAGE', get_bloginfo('stylesheet_directory') .'/images/headers/baruchcollege.jpg' );

add_action( 'after_setup_theme', 'blogsatbaruch_setup' );
function blogsatbaruch_setup(){

/* Add additional default headers: All Photos are from Baruch College Visual Standards Library: http://www.baruch.cuny.edu/visualstandards/photos.htm */

	$blogsatbaruch_dir =	get_bloginfo('stylesheet_directory');
	register_default_headers( array (
		'Baruch' => array (
			'url' => "$blogsatbaruch_dir/images/headers/baruchcollege.jpg",
			'thumbnail_url' => "$blogsatbaruch_dir/images/headers/baruchcollege-thumbnail.jpg",
			'description' => __( 'Baruch College', 'blogsatbaruch' )
		),
		'Elevators' => array (
			'url' => "$blogsatbaruch_dir/images/headers/elevators.jpg",
			'thumbnail_url' => "$blogsatbaruch_dir/images/headers/elevators-thumbnail.jpg",
			'description' => __( 'Elevators', 'blogsatbaruch' )
		),
		'Reading' => array (
			'url' => "$blogsatbaruch_dir/images/headers/reading.jpg",
			'thumbnail_url' => "$blogsatbaruch_dir/images/headers/reading-thumbnail.jpg",
			'description' => __( 'Reading', 'blogsatbaruch' )
		),
		'Streetsign' => array (
			'url' => "$blogsatbaruch_dir/images/headers/streetsign.jpg",
			'thumbnail_url' => "$blogsatbaruch_dir/images/headers/streetsign-thumbnail.jpg",
			'description' => __( 'Street Sign', 'blogsatbaruch' )
		),
		'Turnstiles' => array (
			'url' => "$blogsatbaruch_dir/images/headers/turnstiles.jpg",
			'thumbnail_url' => "$blogsatbaruch_dir/images/headers/turnstiles-thumbnail.jpg",
			'description' => __( 'Turnstiles', 'blogsatbaruch' )
		),
		'VC View' => array (
			'url' => "$blogsatbaruch_dir/images/headers/vcview.jpg",
			'thumbnail_url' => "$blogsatbaruch_dir/images/headers/vcview-thumbnail.jpg",
			'description' => __( 'View from VC', 'blogsatbaruch' )
		),
		'Windows' => array (
			'url' => "$blogsatbaruch_dir/images/headers/windows.jpg",
			'thumbnail_url' => "$blogsatbaruch_dir/images/headers/windows-thumbnail.jpg",
			'description' => __( 'Windows', 'blogsatbaruch' )
		),

	));
}

function remove_twenty_ten_headers(){
	unregister_default_headers( array(
		'berries',
		'cherryblossom',
		'concave',
		'fern',
		'forestfloor',
		'inkwell',
		'path' ,
		'sunset')
	);
}

add_action( 'after_setup_theme', 'remove_twenty_ten_headers', 11 );

And here’s what it looks like:

This new theme is sharper than what previously loaded, and TwentyTen is customizable enough that I think a lot of our users will just keep it as their primary theme.

Bye Bye Userthemes

Finally, I’ve done away Userthemes on Blogs@Baruch. The last two WP upgrades have required hacks to keep the plugin only half-working (I’ve never been able to turn off Userthemes on blogs… once you go Userthemes you’ll never go back!). It’s such an important part of what we do on the system that I wanted to cease relying on such an unstable plugin. Instead, with Tom Harbison’s help, we copied all of our custom themes into the theme library and renamed their folders to the site id for which they were intended. We didn’t activate these themes site wide, but rather went one by one through the blogs, editing the template, stylesheet, and theme settings for each. Not the perfect solution, but it feels more stable than relying on Userthemes.

Those are the hacks that I remember. I’m sure there are a few that I missed.

If you’d like to take a look at the child themes, here they are: Blogs at Baruch BP (child of bp-default) and Blogs at Baruch (child of TwentyTen).

2 thoughts on “Blogs@Baruch, now with BuddyPress!”

  1. Congratulations on a huge task successfully completed! Your new default themes look great. Special thanks for documenting all of this–that’s a giant, generous, contribution to the community right there.

    I’m hoping that I’m going to be able to make a new (working, stable, developed, regularly-updated) version of userthemes available this year. It’s too useful to lose.

  2. Here is a function I found (can’t remember where) that will allow you to just put new header images into the images/header folder of a Twenty Ten child theme. No more hand coding when you want to swap out the available header images. I hope including the code works.

    /* Automatically add header options that you put in the images/header folder to the options users have */
    function cms_theme_headers() {
    	global $themename;
        $list = array();
    	$imagepath = STYLESHEETPATH .'/images/headers/';
    	$imageurl = get_bloginfo('stylesheet_directory');
        $dir_handle = @opendir($imagepath) or die("Unable to open $path"); 
        while($file = readdir($dir_handle)){ 
            if($file == "." || $file == ".."){continue;} 
            $filename = explode(".",$file); 
            $cnt = count($filename); $cnt--; $ext = $filename[$cnt]; 
            if(strtolower($ext) == ('png' || 'jpg')){ 
       	 	  if (!strpos($file, '-thumbnail') > 0) {	 
    				$header = array(
    					'url' => $imageurl .'/images/headers/' .$file,
    					'thumbnail_url' => $imageurl .'/images/headers/' .$filename[0] .'-thumbnail.' .$ext,
    					'description' => __( $filename[0], $themename )
    				);
    				array_push($list, $header);
    		  }
            }
        }
        return $list;
    }
    

Comments are closed.