WordPress.org

Forums

WP-PostRatings
Show number of points on author page? (4 posts)

  1. andy999
    Member
    Posted 1 year ago #

    Is it possible to show how many points a user has on their author page?

    Lets say you have a multi user site and each member can make posts that are voted on with the up/down ratings, is it possible to calculate how many points the user has and show that on their author page?

    https://wordpress.org/plugins/wp-postratings/

  2. Lester Chan
    Member
    Plugin Author

    Posted 1 year ago #

    You can probably get all the post ID that the author has make and base on the post ids, get the post meta "ratings_score" and sum it all up.

  3. andy999
    Member
    Posted 1 year ago #

    I found this little snippet kicking around but it doesn't seem to output anything when I put it on the author page, what am I doing wrong?

    function ac_author_score() {
    
    	$userID = get_the_author_meta( 'ID' );
    	$query = array (
    		'author' => $userID,
    		'posts_per_page' => -1
    	);
    	$queryObject = new WP_Query($query);
    
    	while( $queryObject->have_posts() ) : $queryObject->the_post();
    
    	global $post;
    	$postID = $post->ID;
    
    	$score = $score + intval( get_post_meta( 'ratings_score', $postID, true ) );
    
    	endwhile; 
    
    	wp_reset_query();
    
    	if ( $score > 0 )
    		$score = '+' . $score;
    
    	return $score;
    
    }
    ?>
  4. Lester Chan
    Member
    Plugin Author

    Posted 1 year ago #

    Because the function is returning the $score instead of printing it out?

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.