gdrts_mycred_for_rating_points

Developer Knowledge Level

This content is intended for WordPress developers, and it may require coding knowledge of WordPress, PHP, and JavaScript. Code examples provided here may contain errors or needs some additional coding. Make sure to test the code before using it on a live website!

This filter is executed prior to the points assignment for the rating action. This filter controls the points that will user casting the vote get. The initial value is based on the addon settings and rules, and you can change it based on the additional data provided by the filter.

This filter provides 5 arguments.

Arguments

  • $points: number of points to give to the user.
  • $log_id: id of the vote log entry.
  • $data: array the main rating object data (contains method, series…).
  • $meta: an array containing actual rating, including the vote.
  • $item: object with the rated post or another rating item.

Example

This example will check if the rating method is Stars Rating and will give a different amount of points if the rating value is 5 stars.

add_filter('gdbbx_report_show_link', 'custom__gdrts_mycred_for_rating_points', 10, 5);
function custom__gdrts_mycred_for_rating_points($points, $log_id, $data, $meta, $item) {
  if ($data['method'] == 'stars-rating' && $meta['vote'] == 5) {
    $points = $points * 2;
  }
  return $points;
}
0
0
748
Rate this reference

You are not allowed to rate this post.

Leave a Comment