Function Reference: geodir_update_rating_status_change

Summary

Update comment status when changing the 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
$status
(int|string) (required) The comment status.

Default: None

Change Log

Since: 1.0.0

Source File

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

Source Code

function geodir_update_rating_status_change($comment_id, $status)
{
    if ($status == 'delete') {
        return;
    }
    global $wpdb, $plugin_prefix, $user_ID;

    $comment_info = get_comment($comment_id);

    $post_id = isset($comment_info->comment_post_ID) ? $comment_info->comment_post_ID : '';

    if (!empty($comment_info))
        $status = $comment_info->comment_approved;

    if ($status == 'approve' || $status == 1) {
        $status = 1;
    } else {
        $status = 0;
    }

    $comment_info_ID = isset($comment_info->comment_ID) ? $comment_info->comment_ID : '';
    $old_rating = geodir_get_commentoverall($comment_info_ID);

    $post_type = get_post_type($post_id);

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

    if ($comment_id) {

        $overall_rating = $old_rating;

        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);

        }

    }

}