gdrts_db_vote_logged
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!
When the vote is saved to the database, action gdrts_db_vote_logged is executed. This action provides 3 arguments.
Arguments
- $log_id: ID from the votes log
- $data: main data related to the vote
- $meta: additional data related to the vote
Argument: $data
This argument is an array with main vote information:
- item_id: rating item connected to the gdrts_items database table
- user_id: ID of the user, or 0 for visitor vote
- ref_id: reference log ID if the vote is re-vote
- action: vote or revote
- status: active or replaced
- method: name of the rating method
- logged: date time of the vote
- ip: IP of the voter
- series: name of the series for the rating method
Argument: $meta
This depends on the rating method, and it contains information about the vote.
Example
add_action('gdrts_db_add_vote_to_log', 'custom__gdrts_db_add_vote_to_log', 10, 3); function custom__gdrts_db_add_vote_to_log($log_id, $data, $meta) { // get rating item with all rating data included $item = gdrts_get_rating_item(array('item_id' = $data['item_id'])); // do something with the data }
2 thoughts on “gdrts_db_vote_logged”
Leave a Comment
You must be logged in to post a comment.
How would you find the item that was rated? Specifically in the bbPress Topic/Reply case. Do you need to go into the gdrts_items table?
You can use item_id with the gdrts_get_rating_item() function to get the item (it contains post type, id…): https://support.dev4press.com/kb/article/rating-item-object/