Now-Reading Tweaks v2

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 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.

2 Comments

Comments are closed.

Thank you so much for this post!

I just installed the forked version of Now Reading from the WordPress repository and the only thing that was broken from my old custom templates was this function (didn’t exist) so I added it and now I have my Amazon search capabilities back and my grand custom template.

Thanks!

Copyright © 2004 – 2018 CoffeeBear.net. Powered by WordPress.