如果有人感兴趣的话,我写了三条第一条评论的代码。代码,并将其添加到函数中。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;
}
有没有机会优化代码?还是已经是最优的?
谢谢