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 (gdrts_calculate_stars_rating_item) is used to filter item after the vote calculations have been done after voting.

This filter provides 5 arguments. Using this filter allows modifications to the $item and even modification of the calculated ratings. Do not use if you are not sure what this can do.

Arguments

  • $item: item used to do calculations for.
  • $action: action can be vote or revote.
  • $vote: vote added to the calculation.
  • $max: max vote value.
  • $previous: if $action is a revote, this is the vote being replaced.

Example

add_filter('gdrts_calculate_stars_rating_item', 'custom__gdrts_calculate_stars_rating_item', 10, 5);
function custom__gdrts_calculate_stars_rating_item($item, $action, $vote, $max, $previous) {
  // modify the $item object //

  // return the $item object//
  return $item;
}
1
0
503
Rate this reference

You are not allowed to rate this post.

Comments

Leave a Reply