wpDiscuz - WordPress Comment Plugin
Share:
Notifications
Clear all

[Solved] Report and Flagging API Hooks?


Tetrakern
Posts: 15
Topic starter
(@tetrakern)
Active Member
Joined: 2 years ago

Hello,

I recently started to integrate the Flagging and Report addon. Now, I also ave a custom Moderator role and obviously I want to send moderations a notification when a comment has been flagged. Unfortunately, I can only add one email address. Is there an API hook or something else I can use to send the notification to other recipient as well? This would go well with this custom notification plugin.

15 Replies
Asti
Posts: 4613
 Asti
Support
(@asti)
Support member
Joined: 4 years ago

We'll provide a solution in the next version of the addon. Please wait for the next update. 

7 Replies
Tetrakern
(@tetrakern)
Joined: 2 years ago

Active Member
Posts: 15
Asti
 Asti
Support
(@asti)
Joined: 4 years ago

Support member
Posts: 4613

@tetrakern,

You can fill in the comma-separated email addresses of website administrators, moderators to get the notifications in the "Admin Email" field.

It's located in the Dashboard > wpDiscuz > Settings > Report & Flagging admin page. 

Tetrakern
(@tetrakern)
Joined: 2 years ago

Active Member
Posts: 15

@asti ,

I see. Still, my needs have now evolved beyond this as I'm feeding notifications into a Discord channel now. This is far more efficient and centralized than spamming emails left and right, which drove us crazy anyway.

In regards to that, you may want to think of adding an interface for chat client webhooks anyway. The JSON structure may pose a challenge tho; otherwise it's stupid easy to push messages to channels.

Of course, I need to access the data for this when a report is made or auto-moderation happens. I guess I can intercept the email and pick it apart, probably by writing a JSON as body. But cannot say that's convenient.

Screen Shot 2022 01 21 at 13.07.53
Asti
 Asti
Support
(@asti)
Joined: 4 years ago

Support member
Posts: 4613

@tetrakern,

The hook will be added in the next version.  

Tetrakern
(@tetrakern)
Joined: 2 years ago

Active Member
Posts: 15

@asti 

I see the hooks have been added. Nice. Is there a documentation on them somewhere? Currently, I cannot find the hooks in the API documentation.

Asti
 Asti
Support
(@asti)
Joined: 4 years ago

Support member
Posts: 4613

@tetrakern,

We're really sorry, but API documentation doesn't include the hooks for the addons. 

The following three hooks were added: 

add_action("wpdiscuz_rf_flagged", "my_custom_function");
add_action("wpdiscuz_rf_down_voted", "my_custom_function");
add_action("wpdiscuz_rf_reported", "my_custom_function");

The list of the arguments you can find below: 

   if (!function_exists("my_custom_function")) {
    
    function my_custom_function($args) {
        // $args["email_to"]  - the sent email, that is to whom the email goes
        // $args["email_subject"] -  the email subject@
        // $args["email_message"] -  the email body
        // $args["comment"] - the comment object that has been reported or down voted
        // $args["user"] - the current user object who reports or dislikes the comment, in case of guest this is empty        
    }        
}

Tetrakern
(@tetrakern)
Joined: 2 years ago

Active Member
Posts: 15

@asti 

Thank you.

Tetrakern
Posts: 15
Topic starter
(@tetrakern)
Active Member
Joined: 2 years ago

I just noticed that you apparently cannot change the message for auto-moderation. It is not saved. I wanted to change it into a parsable structure. Took me hours to see that it doesn't save, searching the error on my side.

6 Replies
Asti
 Asti
Support
(@asti)
Joined: 4 years ago

Support member
Posts: 4613

@tetrakern,

Probably you have some js errors on your website.  Please check your JS errors. It seems the problem comes from JS errors. Just press F12, go to the Console tab and check JavaScript errors.

Tetrakern
(@tetrakern)
Joined: 2 years ago

Active Member
Posts: 15

@asti 

There are non JS errors, unfortunately. And you can save the "Report message body" just fine, but not the "Auto-moderation message body". It will always reset to default. It's also not saved via Ajax anyway afaik. The problem occurs on two independent servers. Turning off all plugins and using a standard theme doesn't work either.

Asti
 Asti
Support
(@asti)
Joined: 4 years ago

Support member
Posts: 4613

@tetrakern,

We'll check and get back to you asap.  

Asti
 Asti
Support
(@asti)
Joined: 4 years ago

Support member
Posts: 4613

@tetrakern,

We'll check and get back to you asap.  

This issue will be fixed in the next version. 

Regarding the hook, we need some clarifications. Please let us know what data are needed in your case as arguments. 

Tetrakern
(@tetrakern)
Joined: 2 years ago

Active Member
Posts: 15

@asti 

Essentially what's in the email -- report message, reported comment content/link/id, who submitted the report. Would probably be easier to just put in the whole comment object.

Asti
 Asti
Support
(@asti)
Joined: 4 years ago

Support member
Posts: 4613

Thank you for your clarification, @tetrakern!

 

Share: