I am creating a plugin where i want to restrict a user to do give ratings to the post but not more than once.
function frs_insert_ratings($content) {
if(!is_feed() && !is_home()) {
global $wpdb;
$tablename = $wpdb->prefix . "rating_calculator";
$content.= "<div class='rating'></div>";
global $post;
$postID = $post->ID;
$content.="<form method='post' action=''> <input type='hidden' id='post_id' value='".$postID."'/></form>";
$getarow = $wpdb->get_row( "SELECT * FROM $tablename WHERE post_id = $postID" );
if(!empty($getarow)){
$woke = $getarow->rating_count;
$total = ($woke*15)/100;
$content .= "<span id='woke'> ".$total."% Woke </span>";
}else {
$content .= "<span id='woke'> 0% Woke </span>";
}
}
return $content;
}