Forum Replies Created

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter gusbo

    (@gusbo)

    @hamzahli

    Hi there,

    Yeah, I got it working using the code above. You do have to go into some of the root files of the plugin to get things working so make sure you back everything up first before trying anything.

    Essentially, the link in my first post give you instructions as to how to use the unused ‘comment karma’ column of the wordpress comments table in the database to order your comments. Then the second piece of code which I wrote shows how to pull the voting (thumbs) data from the plugin table of the database and then drop that into the comments karma column of the comments table. There are other things you can use as opposed to the thumb votes, such as the star ratings. Also, the code above only works for the visitor votes but it’s easy enough to update it for user votes as well (likewise for the star ratings).

    Thread Starter gusbo

    (@gusbo)

    I should also point out for anyone looking to do this that what I’ve done will reorder the comments according to thumb votes, not ratings. I’m sure that the script could be easily adapted for that purpose however.

    Thread Starter gusbo

    (@gusbo)

    OK, you can ignore all that previous nonsense. That line of code is all wrong, it’s essentially trying to create a row in a table that doesn’t exist. I blame the fact that it’s half one in the morning and i’m coding when my body thinks I should be drinking.

    I think I’ve nailed it now. I used the code from the previous link i posted which sorts the comments according to the comment_karma in the comments.php of my theme and then added this to the end of the add_vote_comment_thumb function (line 174) in db.php in the plugin code>blg folder:

    $up_qry = sprintf("SELECT visitor_recc_plus FROM %sgdsr_data_comment WHERE comment_id = %s", $table_prefix, $id);
    $votes_up = $wpdb->get_var($up_qry);
    $down_qry = sprintf("SELECT visitor_recc_minus FROM %sgdsr_data_comment WHERE comment_id = %s", $table_prefix, $id);
    $votes_down = $wpdb->get_var($down_qry);
    $votes = $votes_up - $votes_down;
    $votes_qry = sprintf("UPDATE %scomments SET comment_karma = $votes WHERE comment_ID = %s", $table_prefix, $id);
    $wpdb->query($votes_qry);

    This only updates for visitors, not users, as I don’t have folks logging in to vote on my site. It’s pretty straightforward to put that in though. hope this helps someone, cause it’s been bugging me for days!

    Gusbo

Viewing 3 replies - 1 through 3 (of 3 total)