• Hi, I am using this plugin in my website. I have created a page for adding reviews to website. Whenever I add a review using code and database query instead of name I see “Anonymous” there. Is there any settings for this? I dont want to use anonymous as name in review.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Support pear8398

    (@pear8398)

    Hi,

    Thanks for using CusRev.

    Can you share the code that you use to add a review programmatically? If you deactivate our plugin, does the reviewer name still show Anonymous?

    Thread Starter dev1122

    (@dev1122)

    Hi @pear8398,

    Following is the code that I am using to save a review programmatically and getting Anonymous in name every time. Is there any settings for this?

    $rating_number = $_POST[‘rating_number’];
    $product_id = $_POST[‘prod_id’];
    $rev_name = $_POST[‘name’];
    $rev_email = $_POST[’email’];
    $rev_review = $_POST[‘content’];

        $comment_id = wp_insert_comment( array(
            'comment_post_ID'      => $product_id, // <=== The product ID where the review will show up
            'comment_author'       => $rev_name,
            'comment_author_email' => $rev_email, // <== Important
            'comment_author_url'   => '',
            'comment_content'      => $rev_review,
            'comment_type'         => 'review',
            'comment_parent'       => 0,
            'user_id'              => 0, // <== Important
            'comment_author_IP'    => '',
            'comment_agent'        => '',
            'comment_date'         => date('Y-m-d H:i:s'),
            'comment_approved'     => 0,
        ) );
    
        // HERE inserting the rating (an integer from 1 to 5)
        update_comment_meta( $comment_id, 'rating', $rating_number );
    
        echo "Your Review has been submitted successfully!";
    Thread Starter dev1122

    (@dev1122)

    Hi,

    Did you check this code? Is there a way to fix this? Is there any setting from which this Anonymous is generating as a name?

    I will be waiting for your reply!

    Plugin Support pear8398

    (@pear8398)

    Hi,

    I think there is an issue with the variables $rev_name and $rev_email, you can pass a user name and email instead of variables and see if it helps.
    Also, if you use the code to add the review programmatically, it isn’t affected by our plugin features. You can deactivate our plugin and run the code again to see the result.

Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.