I would like to enable ratings for individual authors on my site instead of posts, so that users can rate each other. I just want a star rating system with some text to form some sort of review. I have played around with Lester Chan's WP-PostRatings (http://wordpress.org/extend/plugins/wp-postratings/) but sadly my coding skills are not that good so I couldn't figure out how to modify it. I would really appreciate any help I can get on this.


1 Answer 1


I would create a custom table that stored a) the user doing the rating b) the user being rated c) the rating d) the time of the rating. Between these 4, you should be able to store, aggregate, and effectively query your data with very little overhead or PHP processing.


note: this is pseudocode

function get_user_rating( $user_id ) {
    $rating = get_from_database(
        'SELECT AVG(rating)
        FROM ratings_table
        WHERE user_being_rated = '.$user_id

    return $rating;

function add_user_rating( $rater, $rated, $rating ) {
    //check to see if there is already a rating to avoid duplicate records
    if( already_rated( $rater, $rated ) ) {
        //remove previous rating
        remove_rating( $rater, $rated );
    //insert current rating
        'INSERT INTO ratings_table
        ( user_doing_rating, user_being_rated, rating, time ) VALUE
        ( '.$rater.', '.$rated.', '.$rating.', CURTIME() )'
  • 1
    why not use the usermeta table?
    – Bainternet
    Feb 12, 2012 at 15:18
  • Thanks a lot for your response. I was actually hoping for a bit more assistance. Do you suppose you could tell me how to implement it with WP-PostRatings?
    – user13054
    Feb 12, 2012 at 19:01
  • @user13054 No idea, never touched it.
    – mor7ifer
    Feb 12, 2012 at 21:06
  • 1
    @Bainternet The issue with doing it like that would be the accessibility of the data...the only good way that I can think of to do it is with serialized arrays, containing the same data that would go into the custom table (cpm['rating'], cpm['rater'], etc), that would then be serialized. Since it's serialized, if you wanted to get, for example, the number of people who had rated author with ID 1, you would then need to loop through EVERY rating, unserialize, and get your count, whereas with the method I propose it can actually be handled by MySQL without ANY php.
    – mor7ifer
    Feb 12, 2012 at 21:10
  • Thanks m0r7if3r. I really appreciate your help. Could you possibly provide some sort of code as an example to help me get started? Sorry for being such a noob.
    – user13054
    Feb 12, 2012 at 21:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.