Some time back, I tried to make Rob Miller’s Now-Reading plugin display who’s reading each book on the individual pages. But the PHP code I posted at that time didn’t work like I thought it did, my interests changed and I moved onto other things. Today I had a visitor stop by asking about my broken tweak. So I took another look at the code and I believe I’ve got something 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 “Display name publicly as” from the user’s profile and displays it on the page. I put the function in the functions.php file of the theme I’m using (so any automatic upgrades of the plugin won’t erase it). Then I put < ?php mlm_book_reader() ?> into my custom single.php template and viola!

Note: this has only been tested on WordPress 2.6.2 with Now-Reading 4.4.3.

  • The office popcorn maker finishes popping, you run into the breakroom  to enjoy not the tasty, salty popcorn but to shove your arms inside the popcorn maker to get warm.
  • Your local hardware store is sold out of space heaters, in 5 minutes, in July, at full price.
  • Some poor kid licked your office window and he’s stuck to it.  Fortunately you had your video camera handy to record/upload this phenomenon to YouTube.  Mind you, it would have been nicer to call the fire dept the first day the kid was stuck out there….

This post was inspired by real life events.  Names have been removed to protect the innocent.