Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Guys, I need to know how to do the following:

When I receive a comment ... This comment must be approved by three moderators. To appear on the site.

Anyone know how to do it or some plugin?

share|improve this question
add comment

1 Answer

up vote 9 down vote accepted

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');


?>
share|improve this answer
    
thanks for the feedback We have three owners in the specific site The comment must be approved by each of them. –  Alyson Veras Apr 26 '11 at 3:11
    
this code a moderator can approve more than once to comment? the idea is each of the three, only able to approve a time with 3, the commentary is released –  Alyson Veras Apr 26 '11 at 16:57
    
Nope, a mod can only approve once each comments and its checked with /only allow each mod to approve once if (in_array($current_user->ID,$mods)){ return ''; –  Bainternet Apr 26 '11 at 17:01
    
ok i will test and tell you about it. –  Alyson Veras Apr 28 '11 at 14:46
    
Warning: call_user_func_array() expects parameter 1 to be a valid callback, function 'check_add_approved_count' not found or invalid function name in /home/sitename/wp-includes/plugin.php on line 395 , i add your function in Theme Functions (functions.php) –  Alyson Veras Apr 28 '11 at 19:02
show 23 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.