Now-Reading Tweaks v2

Some time back, I tried to make Rob Miller’s Now-Reading plu­gin dis­play who’s read­ing each book on the indi­vid­ual pages. But the PHP code I posted at that time didn’t work like I thought it did, my inter­ests changed and I moved onto other things. Today I had a vis­i­tor stop by ask­ing about my bro­ken tweak. So I took another look at the code and I believe I’ve got some­thing that works this time.

// Now-Reading Plugin: Get the display name of the book's reader
function mlm_book_reader( $echo=true ) {
	global $book;

	$user_info = get_userdata($book->reader);

	if ( $echo )
		echo $user_info->display_name;
	return $user_info->display_name;

}

This grabs “Dis­play name pub­licly as” from the user’s pro­file and dis­plays it on the page. I put the func­tion in the functions.php file of the theme I’m using (so any auto­matic upgrades of the plu­gin won’t erase it). Then I put < ?php mlm_book_reader() ?> into my cus­tom single.php tem­plate and viola!

Note: this has only been tested on Word­Press 2.6.2 with Now-Reading 4.4.3.

Share and Enjoy:
  • del.icio.us
  • Digg
  • StumbleUpon
  • Twitter
  • Reddit
  • Google Bookmarks
  • Facebook
  • MySpace
  • Yahoo! Buzz
  • Print

Similar Posts

About Mark McKibben

Mark is a data analyst for [REDACTED], currently residing in the Midwest. CoffeeBear is a place for him to spout off about whatever catches his fancy. In his spare time, Mark does a bit of webdev & design. To stalk him more effectively, try following him on Twitter.

Leave a Reply

This work by Mark McKibben is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 United States.