I've been modifying a long abandoned plugin project that provides a Stackoverflow inspired badge system for Wordpress. I have upgraded some of its code so it functions with the new Wordpress version.
You can view the entire code here if you are interested: http://pastebin.com/kCWWLPL2
I want to add a code to the author.php page to list the author's awarded badges. So far, I have only managed to display the logged in user's badges with this working code:
<?php
$user_id = get_current_user_id();
if ($user_id != 0) {
rhb_list_badges(array('user_ID' => $user_id));
}
?>
I was told to use this code to display the author's badges:
<?php
$author = get_user_by( 'slug', get_query_var( 'author_name' ) );
if ($author->ID > 0) {
rhb_list_badges(array('user_ID' => $author->ID));
}
?>
But it does not return anything on the page. Why? What am I doing wrong here? How can I alter the working get_current_user_id code example so that it will display the author's badges and not the logged in user's one?