Function Reference: geodir_update_rating

Summary

Update comment rating.

Global Values

$wpdb
(object) (required) WordPress Database object.

Default: None
$plugin_prefix
(string) (required) Geodirectory plugin table prefix.

Default: None
$user_ID
(int) (required) The current user ID.

Default: None

Package

GeoDirectory

Parameters

$comment_id
(int) (required) The comment ID.

Default: None

Change Log

Since: 1.0.0

Source File

geodir_update_rating() is located in geodirectory-functions/comments_functions.php [Line: 329]

Source Code

function geodir_update_rating($comment_id = 0)
{

    global $wpdb, $plugin_prefix, $user_ID;

    $comment_info = get_comment($comment_id);

    $post_id = $comment_info->comment_post_ID;
    $status = $comment_info->comment_approved;
    $old_rating = geodir_get_commentoverall($comment_info->comment_ID);

    $post_type = get_post_type($post_id);

    $detail_table = $plugin_prefix . $post_type . '_detail';

    if (isset($_REQUEST['geodir_overallrating'])) {

        $overall_rating = $_REQUEST['geodir_overallrating'];

        if (isset($comment_info->comment_parent) && (int)$comment_info->comment_parent == 0) {
            $overall_rating = $overall_rating > 0 ? $overall_rating : '0';

            if (isset($old_rating)) {

                $sqlqry = $wpdb->prepare("UPDATE " . GEODIR_REVIEW_TABLE . " SET
						overall_rating = %f,
						status		= %s,
						comment_content	= %s 
						WHERE comment_id = %d ", array($overall_rating, $status, $comment_info->comment_content, $comment_id));

                $wpdb->query($sqlqry);

                //update rating
                geodir_update_postrating($post_id, $post_type);

            }
        }
    }


}