Viewing 15 posts - 1 through 15 (of 18 total)
  • Author
    Posts
  • #3260
    edering
    Participant

    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.

    #3261
    Vladimir
    Keymaster

    There 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.

    #3262
    edering
    Participant

    Thanks. So that can be applied on a per User (person) level?

    #3263
    Vladimir
    Keymaster

    Yes. You can set the same restriction for a user at user profile too.

    #3264
    edering
    Participant

    thanks

    #3265
    edering
    Participant

    wait, 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.

    #3266
    Vladimir
    Keymaster

    Use 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.

    #4164
    rheinstars-koeln
    Participant

    Hi,
    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.

    #4166
    Vladimir
    Keymaster

    Hi @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.

    #5142
    dumagroup
    Participant

    Hi 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?

    #5143
    Vladimir
    Keymaster

    Hi @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.

    #7921
    animage
    Participant

    Hi 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

    #7923
    animage
    Participant

    OK, I found it !

    #7924
    Vladimir
    Keymaster

    Hi @animage,

    Thanks for letting me know.

    #7925
    animage
    Participant

    Now 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

Viewing 15 posts - 1 through 15 (of 18 total)
  • You must be logged in to reply to this topic.