Change WordPress user roles and capabilities › Forums › Restrict or Permit access inside WordPress – how to › Restrict access to content by Author in Media Library
- This topic has 17 replies, 6 voices, and was last updated 2 years, 4 months ago by Vladimir.
-
AuthorPosts
-
20/01/2017 at 14:49 #3260ederingParticipant
We have URE Pro. We already restrict access to Media Library by User. But, for those who have access to Media, can we further restrict WHICH Media based on the Author who uploaded it? The issue is one User’s job is to upload sensitive materials that only Board Members can see. But right now any one can see them in media. We’d like to say: ABC has access to Media, but cannot see files uploaded by the “boardadmin” user. In case it helps, we also use the Plugin Media Library Assistant.
20/01/2017 at 15:24 #3261VladimirKeymasterThere is no “except items own by some user” feature.
If you turn ON “Own data only” checkbox for role at “Edit Posts” then user with such role will see just his own media library items only at Media Library and his own posts/pages only at Posts/Pages list too.
20/01/2017 at 15:37 #3262ederingParticipantThanks. So that can be applied on a per User (person) level?
20/01/2017 at 15:39 #3263VladimirKeymasterYes. You can set the same restriction for a user at user profile too.
20/01/2017 at 15:44 #3264ederingParticipantthanks
20/01/2017 at 15:47 #3265ederingParticipantwait, I just realized you are saying that if I do this, that is also means they can only edit Posts/Pages that the User authored. We need this targeted to only Media. I created all the Pages (and some Posts) as the Admin. But there is a staff that needs to be able to edit them.
21/01/2017 at 01:41 #3266VladimirKeymasterUse this workaround:
add_filter('ure_restrict_edit_post_type', 'exclude_posts_from_edit_restrictions'); function exclude_posts_from_edit_restrictions($post_type) { global $current_user; $restrict_it = true; if ($current_user->user_login=='your_user_login_here') { if ($post_type!=='attachment') { $restrict_it = false; } } return $restrict_it; }
It applies ‘edit restrictions’ set for the user to the ‘attachment’ post type only.
10/09/2017 at 17:59 #4164rheinstars-koelnParticipantHi,
sorry if this might be seen as threadjackin….
im am looking for almost the same thing but just the other way around:
i want to keep my access restrictions that work but want to disable any restrictions for attachments.
reason for this: i am using an addon called WP Media folder(https://www.joomunited.com/wordpress-demo/wp-media-folder/) that does not seem to work in combination with URE.
When i remove the restrictions from a certain user it works, but as soon as i restrict something the user does only see his uploads and only when using the media library entry in the menu section and he can olny access the media root when trying to add media to a page.I was hoping that removing attachment restrictions from attachments but keeping it for the rest might be a good work around.
11/09/2017 at 05:31 #4166VladimirKeymasterHi @rheinstars-loeln,
try to add this code to your active theme functions.php file:
add_filter('ure_restrict_edit_post_type', 'exclude_attachments_from_edit_restrictions'); function exclude_attachments_from_edit_restrictions($post_type) { $restrict_it = true; if (current_user_can('author')) { if ($post_type=='attachment') { $restrict_it = false; } } return $restrict_it; }
Replace ‘author’ role inside with any other role, for which you need allow access to all attachments in spite of edit restrictions set for posts or pages.
20/09/2018 at 07:37 #5142dumagroupParticipantHi Vladimir,
i tried this but it did not work for me.
I am trying to restrict users to only have access/manage their own media that they have uploaded.
Hopefully this is available?20/09/2018 at 14:23 #5143VladimirKeymasterHi @dumagroup,
If you turn ON “Own data only” checkbox for role at “Edit Posts” then user with such role will see just his own media library items only at Media Library and his own posts/pages only at Posts/Pages list too.
So you don’t need to try code recipes from above in order to restrict users to only have access/manage their own media that they have uploaded.
03/05/2022 at 11:07 #7921animageParticipantHi Vladimir,
I’m using a french version of User Role Editor Pro and I don’t find the “Own data Only” checkbox.
Can you tell me where to find it or make a screencapture ?Bests regards
03/05/2022 at 12:06 #7923animageParticipantOK, I found it !
03/05/2022 at 12:08 #792403/05/2022 at 12:11 #7925animageParticipantNow that “Own data only” it’s ok for the medias.
Got another pb : I created a CPT called publi_cgts with the plugin CPTUI.
I autorized the rôle to create and edit this CPT, it’s okay. But we need it to attach an article to a catégory when publishing.
I don’t see the “category” assignation option in the article page.
To have it, I must autorize the rôle to “edit the category”. But when doing this, the “Category” menu appear in the WP Admin and this rôle can edit all the category in the general category WP menu.
How to let the user assign it’s article in a restricted number of category ?Bests regards
-
AuthorPosts
- You must be logged in to reply to this topic.