Does this plugin come with the feature of emailing admin

Does this plugin come with the feature of emailing admin when a comment is reported? Or flagging the reported comments in the admin bar?

I'm not always in the Admin section, so could conceivably miss some reports.

  • Vaughan

    Hi @Muted Industries,

    Sorry for the delay.

    Currently there is no functionality in the plugin for sending out email notifications.

    you would need to custom code this into the plugin.

    As a simple bit of code. You could try this.

    Open moderation.php

    Find the following function (around lines 343-366)

    function moderation_process_submission() {
    	global $wpdb, $user_id;
    
    	$user_id = get_current_user_id();
    
    	$user_email = '';
    	if (isset($_POST['report_author_email'])) {
    		$user_email = $_POST['report_author_email'];
    	}
    
    	if ( empty( $user_email ) && !empty( $user_id ) ) {
    		$user_email = $wpdb->get_var($wpdb->prepare("SELECT user_email FROM " . $wpdb->users . " WHERE ID = %d", $user_id));
    	}
    
    	$post_type = $_POST['object_type'];
    	$post_id = $_POST['object_id'];
    	$report_reason = $_POST['report_reason'];
    	$report_note = $_POST['report_note'];
    
    	$wpdb->query($wpdb->prepare("INSERT IGNORE INTO " . $wpdb->base_prefix . "moderation_reports
    	(report_blog_ID, report_object_type, report_object_ID, report_reason, report_note, report_user_ID, report_user_email, report_user_IP, report_stamp, report_date, report_date_gmt)
    	VALUES
    	('" . $wpdb->blogid . "', %s, %d, %s, %s, %d, %s, %s, '" . time() . "', '" . current_time('mysql') . "', '" . get_gmt_from_date( current_time('mysql') ) . "')", $post_type, $post_id, $report_reason, $report_note, $user_id, $user_email, $_SERVER['REMOTE_ADDR']));
    }

    Replace the above function with the following:

    function moderation_process_submission() {
    	global $wpdb, $user_id;
    
    	$user_id = get_current_user_id();
    
    	$user_email = '';
    	if (isset($_POST['report_author_email'])) {
    		$user_email = $_POST['report_author_email'];
    	}
    
    	if ( empty( $user_email ) && !empty( $user_id ) ) {
    		$user_email = $wpdb->get_var($wpdb->prepare("SELECT user_email FROM " . $wpdb->users . " WHERE ID = %d", $user_id));
    	}
    
    	$post_type = $_POST['object_type'];
    	$post_id = $_POST['object_id'];
    	$report_reason = $_POST['report_reason'];
    	$report_note = $_POST['report_note'];
    
    	$wpdb->query($wpdb->prepare("INSERT IGNORE INTO " . $wpdb->base_prefix . "moderation_reports
    	(report_blog_ID, report_object_type, report_object_ID, report_reason, report_note, report_user_ID, report_user_email, report_user_IP, report_stamp, report_date, report_date_gmt)
    	VALUES
    	('" . $wpdb->blogid . "', %s, %d, %s, %s, %d, %s, %s, '" . time() . "', '" . current_time('mysql') . "', '" . get_gmt_from_date( current_time('mysql') ) . "')", $post_type, $post_id, $report_reason, $report_note, $user_id, $user_email, $_SERVER['REMOTE_ADDR']));
    
        $admin_email_msg = 'A new moderation report has been submitted, please login to the dashboard to check moderation submissions';
    
        switch_to_blog(1);
        $main_admin_email = get_option( 'admin_email' );
        restore_current_blog();
        wp_mail( $main_admin_email, 'Moderation Report Submitted', $admin_email_msg);
        }

    Hopefully, that should now send an email to the admin email address (The address on your main site in settings > general.

    Hope this helps