Support » Plugin: WP-PostRatings » Execute extra SQL on post rating

  • Hello,

    I have been using this plugin on my site for the past two years, and have amassed over 450,000 total votes on 1000 posts. But we are going to be moving away from using this plugin to an in built function in our new theme to display ratings. The new function requires meta-data to be created in the wp_postmeta table. Because our site has quite a lot of traffic, and rates are being cast almost constantly, what I would like to do is edit this plugin, so that every time a vote is cast using WP-PostRatings, the meta data is created, or updated, the wp_postmeta table. I have a SQL query that can do this for each post individually, but I do not have the PHP knowledge to know how to integrate this with the existing plugin.

    I would imagine I need to store the SQL in a new function but I have no idea what to do after that. Can anyone help?

    The (complicated) SQL query is shown below. Any help is greatly appreciated.

          ('a:', COUNT(rating_id), ':{',
            (SELECT CONCAT( GROUP_CONCAT(meta_data_vote SEPARATOR ''), '}')
              (SELECT CONCAT
                 @curRow := @curRow + 1,
                ) AS meta_data_vote
               FROM $wpdb->ratings JOIN
                 (SELECT @curRow := -1 AS j) r
                  WHERE rating_postid = @post_id
                    and rating_rating > 0
                 )AS meta_data_votes
          ) AS new_ratings_meta_data
      FROM wp_ratings l
      WHERE rating_postid = @post_id
        and rating_rating > 0);

  • The topic ‘Execute extra SQL on post rating’ is closed to new replies.