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

Question replying to their own comments

2 Posts
2 Users
0 Reactions
29 Views
Posts: 4
Topic starter
(@big-old)
Active Member
Joined: 1 month 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: 7907
 Asti
Support
(@asti)
Illustrious Member
Joined: 7 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: