• Resolved Behi

    (@behzadr89)


    Hi there.
    I need code for dont allow users for write comment to products who has a comment. i wanna allow them for write comment for only products that has not comment.
    in other words users cant leave comments for products that has comment.
    Thanks.

    The page I need help with: [log in to see the link]

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Support gVectors Support

    (@gvectorssupport)

    @behzadr89,

    You can use the following hook code:

    add_filter("wpdiscuz_form_render", function ($output, $commentsCount, $currentUser) {
        global $post;
       if ($commentcount = get_comments_number( $post->ID )>1) {
          $output = "Your custom message";
       }
       return $output;
    }, 10, 3);

    Just change the “Your custom message” part as you like.

    Here is an instruction on how to easily add custom code in WordPress (without Breaking Your Site): https://www.wpbeginner.com/plugins/how-to-easily-add-custom-code-in-wordpress-without-breaking-your-site/

    Thread Starter Behi

    (@behzadr89)

    Hi @gvectorssupport
    Thank you for kindly reply.
    the cod you sent work pretty good, but after adding the below code for showing recommended products after “Custom message” the cod stop working.

    add_filter(“wpdiscuz_form_render”, function ($output, $commentsCount, $currentUser) {
    global $post;
    if ($commentcount = get_comments_number( $post->ID )>1) {
    $output = “Your custom message”;
    }
    return $output;
    }, 10, 3);
    echo do_shortcode(‘[electro_vc_products_multi_category sortby=”mostrated” orderby=”ASC” title=” recomended products for leaving comment ” limit=”3″]’).”;`

    Plugin Support gVectors Support

    (@gvectorssupport)

    Dear Behi,

    For deeper customization, I may suggest you contact us via sales[at]gvectors.com email address and send a list of requirements you’d like to have.

    Currently, we have plugin customization and custom addon development services at the gVectors Team. They can assess the custom work and create it for you. Just

    Thread Starter Behi

    (@behzadr89)

    Dear @gvectorssupport yes befor i just ordered some actions.
    now you sent me this code and it works well. but the only thing that have to know is, when a comment wroten for a product and wating fo admin approving, this cod count that as a product comment.
    i wanna allow users for write comment for only products that has not comment even wating for approving comment. so please witch filter have to add for this cod ?

    add_filter("wpdiscuz_form_render", function ($output, $commentsCount, $currentUser) {
        global $post;
       if ($commentcount = get_comments_number( $post->ID )>1) {
          $output = "Your custom message";
       }
       return $output;
    }, 10, 3);
    Plugin Support gVectors Support

    (@gvectorssupport)

    Hi Behi,

    Please use this one instead of the one we’ve provided in the post above:

    add_filter("wpdiscuz_form_render", function ($output, $commentsCount, $currentUser) {
        global $post;
        $comments = get_comments([
            "post_id" => $post->ID,
            "status" => "all"
        ]);
    
        if (count($comments) > 0) {
            $output = "Your custom message";
        }
        return $output;
    }, 10, 3);
    Thread Starter Behi

    (@behzadr89)

    It’s impressive ,My Thumb is up for you dear @gvectorssupport . solved

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘comment moderate’ is closed to new replies.