Okay
  Print

Manually editing user rating on a post

To manually edit the user rating on a post add the following to your child theme's functions.php file:

function ghostpool_update_average_user_rating() {
  
    $post_id = 123; 
    
    $rating_data = array();
    
    $rating_data['average_rating'] = 7;
    
    $rating_data['rating_sum'] = 100; // Total of all the user ratings added together
    
    $rating_data['user_votes'] = 1;
    
    $rating_data['criteria'] = array(
        array( 'criterion' => 'Criterion 1', 'rating' => 5 ),
        array( 'criterion' => 'Criterion 2', 'rating' => 2 ),
        array( 'criterion' => 'Criterion 3', 'rating' => 3 ),
    );    
        
    update_post_meta( $post_id, 'gp_post_user_rating_data', $rating_data );
    update_post_meta( $post_id, 'gp_average_user_rating', $rating_data['average_rating'] );
    update_post_meta( $post_id, 'gp_user_votes', $rating_data['user_votes'] );
    
}
add_action( 'init', 'ghostpool_update_average_user_rating' );

Edit the post ID, average rating, rating sum, user votes and criterion data to what you want. If the post has no criteria ratings replace this with:

$rating_data['criteria'] = array();  

Now go to your post and refresh the page. Once the user rating has been updated remove this code from your functions.php file.