Storing User Statistics
-
is there anyway to store user stats? how many times voted how many negative how many positive votes. which posts voted etc. i need those stats. thank you.
Viewing 2 replies - 1 through 2 (of 2 total)
-
Hello,
The plugin does not store any user information.
Regards
Thank you. i made some modifications on thumbs_rating_add_vote_callback function. And i dont success.
in fuct this is not about the plugin but i want to ask that question to experienced coder.
update_user_meta is not updating. if you have sparetime can you please check my code. thank you.
function thumbs_rating_add_vote_callback() { // Check the nonce - security check_ajax_referer( 'thumbs-rating-nonce', 'nonce' ); global $wpdb; // Get the POST values $post_ID = intval( $_POST['postid'] ); $type_of_vote = intval( $_POST['type'] ); // Get the currebt User Id if( $post_ID == '' ) $post_ID = get_the_ID(); $user_ID = get_current_user_id(); // Check the type and retrieve the meta values global $parameter_name; global $parameter_value; if ( $type_of_vote == 1 ){ $meta_name = "_thumbs_rating_up"; $parameter_name = 'positive_votes'; //$current_user_positive_votes = get_user_meta($user_ID, $parameter_name, true); $current_user_positive_votes = get_user_meta($user_ID, $parameter_name, true) != '' ? get_user_meta($user_ID, $parameter_name, true) : '0'; if($current_user_positive_votes == '') { add_user_meta($user_ID, $parameter_name, 0, false); //$current_user_positive_votes = get_user_meta($user_ID, $parameter_name, true); $current_user_positive_votes = get_user_meta($user_ID, $parameter_name, true) != '' ? get_user_meta($user_ID, $parameter_name, true) : '0'; } $parameter_value = $current_user_positive_votes + 1; }elseif( $type_of_vote == 2){ $meta_name = "_thumbs_rating_down"; $parameter_name = 'negative_votes'; //$current_user_negative_votes = get_user_meta($user_ID, $parameter_name, true); $current_user_negative_votes = get_user_meta($user_ID, $parameter_name, true) != '' ? get_user_meta($user_ID, $parameter_name, true) : '0'; if($current_user_negative_votes == '') { add_user_meta($user_ID, $parameter_name, 0, false); //$current_user_negative_votes = get_user_meta($user_ID, $parameter_name, true); $current_user_negative_votes = get_user_meta($user_ID, $parameter_name, true) != '' ? get_user_meta($user_ID, $parameter_name, true) : '0'; } $parameter_value = $current_user_negative_votes + 1; } // Retrieve the meta value from the DB $thumbs_rating_count = get_post_meta($post_ID, $meta_name, true) != '' ? get_post_meta($post_ID, $meta_name, true) : '0'; $thumbs_rating_count = $thumbs_rating_count + 1; // Update the meta value update_post_meta($post_ID, $meta_name, $thumbs_rating_count); update_user_meta( $user_id, $parameter_name, $parameter_value ); //Update total Votes of current user //$total_votes = get_user_meta($user_ID, 'total_votes', true); $total_votes = get_user_meta($user_ID, 'total_votes', true) != '' ? get_user_meta($user_ID, 'total_votes', true) : '0'; if($total_votes == '') { add_user_meta($user_ID, 'total_votes', 0, false); $total_votes = get_user_meta($user_ID, 'total_votes', true) != '' ? get_user_meta($user_ID, 'total_votes', true) : '0'; } $total_votes = $total_votes + 1 ; //$total_votes_new_value_string = "".$total_votes_new_value; update_user_meta($user_id, 'total_votes', $total_votes); insert_user_stats($post_ID, $user_ID); $results = thumbs_rating_getlink($post_ID, $type_of_vote); die($results); } add_action( 'wp_ajax_thumbs_rating_add_vote', 'thumbs_rating_add_vote_callback' ); add_action('wp_ajax_nopriv_thumbs_rating_add_vote', 'thumbs_rating_add_vote_callback'); endif;
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Storing User Statistics’ is closed to new replies.