admin管理员组文章数量:1287610
I'd like to restrict users to only see/manage only their own uploads. However, there's a requirement to allow one than one account to manage these uploads. It cannot just be the person who originally uploaded them.
Is this possible?
I'd like to restrict users to only see/manage only their own uploads. However, there's a requirement to allow one than one account to manage these uploads. It cannot just be the person who originally uploaded them.
Is this possible?
Share Improve this question asked Sep 13, 2021 at 16:03 BobsBurgers2356BobsBurgers2356 11 Answer
Reset to default 0Add this code in your Functions.php. This code help you to show user only their own uploads but admin can see all media uploaded by other users and this code is tested on current wordpress Version 5.8
// Limit media library access
add_filter( 'ajax_query_attachments_args', 'wpb_show_current_user_attachments'
);
function wpb_show_current_user_attachments( $query ) {
$user_id = get_current_user_id();
if ( $user_id && !current_user_can('activate_plugins') &&
!current_user_can('edit_others_posts
') ) {
$query['author'] = $user_id;
}
return $query;
}
本文标签: content restrictionLimit users to specific uploads
版权声明:本文标题:content restriction - Limit users to specific uploads 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741317906a2372028.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论