0

Two thinks concerning comments moderation.

First task: I am using standard Wordpress moderation settings. First comment has to be moderated. Rest not.

By default Wordpress check if ONE previous comment was approved. How to change this number to 3 comments? There is 'pre_comment_approved' but I don't now how to use it. add_filter?? Are there any moderation capability settings for this?

Second task: I am trying to add new user role Subscriber-To-Moderate. This role would inherit all the capability of Subscriber and will have one additional capability. Each comment has to be moderated. This is for user who "behave" and every comment has to be moderated.

Thank you for help

2

1 Answer 1

0

I wrote the code for three first comments to be moderated, if someone interested. Code below, and to be added to functions.php

add_filter('pre_comment_approved', 'moderate_commentator', 10, 2);  

function moderate_commentator( $approved, $commentdata ){
$args = array(
    'user_id' => $commentdata['user_ID'], //get user_ID of the commnet author
    'status' => 'approve',   //approved comments only
    'count' => true //return only the count 
);
$comments = get_comments( $args );
$comments_Num = 3;   // number of comments to moderate

if( $comments < $comments_Num )        
    $approved = 0;   // set - comment is marked for moderation as "Pending" if less than 3 comments approved  

return $approved;

}

Any chance to optimmize the code? or is already optimal?

thanks

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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