wordpress上传限制_如何在WordPress Admin中将作者限制为自己的帖子

wordpress上传限制

If you run a multi-author site, then you know that the post screen can get a bit crowded. Recently one of our users asked if it was possible to limit the WordPress posts screen to only show authors their own post. In this article, we will show you how to limit authors to only view and manage their own posts in WordPress admin.

如果您运行一个多作者网站,那么您就会知道发帖屏幕可能会有些拥挤。 最近,我们的一位用户询问是否可以将WordPress帖子屏幕限制为仅向作者显示自己的帖子。 在本文中,我们将向您展示如何限制作者仅在WordPress管理员中查看和管理他们自己的帖子。

Hiding posts from other authors in WordPress
影片教学 (Video Tutorial)

演示地址

If you don’t like the video or need more instructions, then continue reading.

如果您不喜欢该视频或需要更多说明,请继续阅读。

First thing you need to do is install and activate the Manage/View Your Posts Only plugin. This plugin works out of the box, and there are no settings for you to configure.

您需要做的第一件事是安装并激活“ 仅管理/查看您的帖子”插件。 该插件可以直接使用,没有可供您配置的设置。

If you are logged in with an administrator user role, then you will be able to see all the posts on your site. Users with other user roles will only be able to see their own posts.

如果您以管理员用户身份登录,那么您将能够看到您网站上的所有帖子。 具有其他用户角色的用户将只能看到他们自己的帖子。

如何允许编辑者查看所有帖子 (How to Allow Editors to View All Posts)

The problem with the plugin mentioned above is that it only allows administrators to view all posts. Many WordPress sites have editors responsible for proof-reading articles submitted by other authors and guest contributors. Using this plugin will restrict editors to only their own posts.

上面提到的插件的问题在于它仅允许管理员查看所有帖子。 许多WordPress网站都有编辑人员负责其他作者和访客贡献者提交的校对文章。 使用此插件将限制编辑者只能发表自己的帖子。

In this situation, the plugin we mentioned above will be useless for you.

在这种情况下,我们上面提到的插件将对您无用。

Instead, you can add this code in your theme’s functions.php file or a site-specific plugin.

相反,您可以将此代码添加到主题的functions.php文件或特定站点的插件中


function posts_for_current_author($query) {
	global $pagenow;

	if( 'edit.php' != $pagenow || !$query->is_admin )
	    return $query;

	if( !current_user_can( 'edit_others_posts' ) ) {
		global $user_ID;
		$query->set('author', $user_ID );
	}
	return $query;
}
add_filter('pre_get_posts', 'posts_for_current_author');

This code allows any users with the capability to edit other’s posts to view all posts. This means editors and administrators will be able to see all posts. Users with other roles like contributor or authors will only see their own posts.

此代码允许任何用户能够编辑其他人的帖子以查看所有帖子。 这意味着编辑者和管理员将能够看到所有帖子。 具有其他角色(例如贡献者或作者)的用户将只能看到他们自己的帖子。

If you are using custom user roles on your site, then you need to keep in mind that users who can edit posts added by other users will also be able to see them.

如果您在网站上使用自定义用户角色 ,则需要记住,可以编辑其他用户添加的帖子的用户也将能够看到它们。

That’s all, we hope this article helped you learn how to hide posts from other authors in WordPress admin area. You may also want to take a look at our tutorial on how to hide unnecessary items from WordPress admin with Adminimize.

仅此而已,我们希望本文能帮助您了解如何在WordPress管理区域中隐藏其他作者的帖子。 您可能还想看一下我们的教程,该教程介绍了如何使用Adminimize 从WordPress管理员隐藏不必要的项目

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Google+.

如果您喜欢这篇文章,请订阅我们的YouTube频道 WordPress视频教程。 您也可以在TwitterGoogle+上找到我们。

翻译自: https://www.wpbeginner.com/plugins/how-to-limit-authors-to-their-own-posts-in-wordpress-admin/

wordpress上传限制

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值