3 moderators to approve comment

you can use comment_unapproved_to_approved action hook to call your function which will use a commentmeta field to count how many times that comment has been approved or by how many users and if it’s less then 3 then we updated the comment to not approved :

update

I’m posting an updated code in the form of a plugin which fixes a few typos:

<?php
/*
Plugin Name: 3-comment-mod
Plugin URI: http://en.bainternet.info
Description: Answer to http://wordpress.stackexchange.com/questions/15574/3-moderators-to-approve-comment/15595#15595
Version: 1.0
Author: Bainternet
Author URI: http://en.bainternet.info
*/

if(!function_exists('check_add_approved_count')) {

    function check_add_approved_count($comment){
        global $current_user;
        get_currentuserinfo();
        //respect the admin comments approved by one approval
        if (current_user_can('manage_options')){
            return '';
        }
        $mods = get_comment_meta($comment->comment_ID,'approved_by',true);
        if(!empty($mods) && is_array($mods)){

            //only allow each mod to approve once
            if (in_array($current_user->ID,$mods)){
                return '';
            }else{

                //here we check the count
                if (count($mods) < 3){
                    //if less then 3 then
                    //we add the current mod to the approving list 

                    $mods[] = $current_user->ID;
                    update_comment_meta($comment->comment_ID,'approved_by',$mods);

                    //and revert back the comment to not approved
                    $commentarr = get_comment($comment->comment_ID, ARRAY_A);
                    $commentarr['comment_approved'] = 0; 
                    wp_update_comment($commentarr);
                }
            }
        }
        //if we got here it means that this is the first approval 
        //so we just add the user to the list and revert back the comment to not approved
        $mods[] = $current_user->ID;
        update_comment_meta($comment->comment_ID,'approved_by',$mods);

        //and revert back the comment to not approved
        $commentarr = get_comment($comment->comment_ID, ARRAY_A);
        $commentarr['comment_approved'] = 0; 
        wp_update_comment($commentarr);
    }
}

add_action('comment_unapproved_to_approved','check_add_approved_count');


?>

Leave a Comment

error code: 523