WordPress插件修改逻辑

时间:2011-08-30 19:27:57

标签: php wordpress-plugin wordpress

我正在使用一个名为Semi Private Comments的非常简单的插件,该插件几乎可以完成我需要的任何操作,它隐藏了其他用户的评论,并且只允许评论的作者和管理员查看评论。我的问题是该插件允许任何人查看任何管理员评论。我希望它能够在管理员和任何用户之间保持一对一对话的评论。

我真的不太了解PHP以修改插件逻辑并且正在寻求一些帮助。

这是代码。

if (current_user_can('edit_users') ||   // user is admin, or 
        $user_matched==1 ||                 // user is original author, or
        $comment->user_id == 1)             // comment author is admin
    {
        return $content;
    }
    else
    {
        $hidden_comment_text = get_option('spc_hidden_comment_text');
        return $hidden_comment_text;
    }
}
else
{
    return $content;
}

1 个答案:

答案 0 :(得分:1)

我认为删除$comment->user_id == 1应该可以解决问题

if (current_user_can('edit_users') ||   // user is admin, or 
    $user_matched==1)                 // user is original author
{
    return $content;  // Only admins and authors of the comment can read
}
else
{
    $hidden_comment_text = get_option('spc_hidden_comment_text');
    return $hidden_comment_text;
}

顺便说一句,你发布的代码已经不完整,缺少以下部分的if语句

}
else
{
    return $content;
}