The effects of alcohol on sustanon 250 leucine for – real weight loss & bodybuilding benefits?
replying to their o...
 
Share:
Notifications
Clear all

Limited Support

Our team is currently on holiday, so support will be limited during this period. Response times may be slower than usual, and some inquiries may be delayed.
We appreciate your patience and understanding, and we’ll resume our usual support by the end of August.

 

Question replying to their own comments

2 Posts
2 Users
0 Reactions
207 Views
Posts: 4
Topic starter
(@big-old)
Active Member
Joined: 5 months ago

Hi, I don't know if it's normal but some users are abusing the replies.. how can I avoid users replying to their own comments?

1 Reply
Asti
Posts: 8075
 Asti
Support
(@asti)
Illustrious Member
Joined: 8 years ago

Hi,

Use this hook code: 

add_action("wpdiscuz_before_wp_new_comment", function ($commentdata) {
    if (!empty($commentdata["user_id"]) && !empty($commentdata["comment_parent"])) {
        $parent_comment = get_comment($commentdata["comment_parent"]);

        if ($parent_comment instanceof WP_Comment) {

            $parent_comment_user_id = (int)$parent_comment->user_id;
            $comment_user_id        = (int)$commentdata["user_id"];

            if ($parent_comment_user_id === $comment_user_id) {
                wp_die(esc_html__("You can not reply to own comment!", "wpdiscuz"));
            }

        }

    }
});

Helpful article: https://www.wpbeginner.com/plugins/how-to-easily-add-custom-code-in-wordpress-without-breaking-your-site/

Reply
Share: