如何使帖子仅对以下对象可见:
帖子作者,无论其用户角色如何。
来自特定用户角色的所有用户。
除此之外,任何人都不应该看到这篇文章。
我应该如何处理这个问题。
请注意,我在WP中只有三个用户角色。管理员和其他2个自定义角色。
如何使帖子仅对以下对象可见:
帖子作者,无论其用户角色如何。
来自特定用户角色的所有用户。
除此之外,任何人都不应该看到这篇文章。
我应该如何处理这个问题。
请注意,我在WP中只有三个用户角色。管理员和其他2个自定义角色。
为您的自定义角色提供“read\\u member\\u posts”或其他功能。然后可以对\\u content()应用筛选器
add_filter( \'the_content\', \'my_wpse20347_filter\' );
function my_wpse20347_filter( $content )
{
global $post;
if( author_can( $post->ID, \'edit_posts\' ) || current_user_can( \'read_member_posts\' ) )
{
return $content;
}
else
{ // Everyone else sees this in place of the content.
return \'<p>Only members may view this post</p>\';
}
}
我们已经在WPSE Plugin Repository 这正是贝因特写的。
刚刚注意到3.1添加了一个新的过滤器来定制查询:posts\\u子句。我所能找到的只是,不用使用单独的查询过滤器,如posts\\u where或posts\\u join,您可以一次性编辑它们。我想知道是否有人可以举例说明新的“posts\\u子句”过滤器的用法?