Can’t print out returned value

Correct way to get the ratings for individual authors.

This is for the author.php page. If you want to display it elsewhere on your site, for example to show the number of likes for the currently logged in user, then use get_current_user_id( ‘ID’ ); in place of get_the_author_meta.

 <?php 

    function author_rating_total() {
       $user_id = get_the_author_meta( 'ID' );
       $query = array (
           'author' => $user_id,
           'suppress_filters' => 'true',
           'posts_per_page' => -1
       );
       $queryObject = new WP_Query($query); while($queryObject->have_posts()) : $queryObject->the_post();

       $post_ratings_data = get_post_custom(get_the_id());
       $post_ratings_score = intval($post_ratings_data['ratings_score'][0]);

       $ratings_array[] = $post_ratings_score;

       endwhile; 

       $ratings_sum = array_sum($ratings_array);

       if ($ratings_sum > 0) {
             $ratings_sum = '' . $ratings_sum;
       }

       echo $ratings_sum;   

       wp_reset_query();
    }
    ?>

    <?php 

    echo author_rating_total();


    ?>