Limit Media Library Access to Specific Folders


I have a site that will host about 100 “Clubs”. When users are created, I am assigning them a “Club Leader” Role that identifies them as being a part of a club in general, but I am using a custom meta field in the wp_usermetatable to assign a specific club to that user. I am not using Roles for each individual club because there will be so many of them, and that seems difficult to handle from an admin perspective — I’m not opposed to using Roles if that’s the best option, though.

What I want to achieve is to limit Club Leaders’ access in the Media Library to a shared folder that all Club Leaders can access, AND a folder that only club leaders in a specific club can access.

So, consider the following media library folder structure:

death star plans
   shared content
   ultimate club
   ultra club
   super club
      copy of death star plans 

John and Daisy both have the “Club Leader” Role, but John has a “club” meta key with the value “super club” and Daisy has a “club” meta key with the value “ultimate club”. So, John and Daisy cannot see the “death star plans” or the “evidence” folder, but they can both see and access the “club” folder and the “shared content” folder — however, John can see and access the “super club” folder and its sub folders, but Daisy cannot. She can see and access “ultimate club”, but John cannot. Keep in mind that there will be about 100 clubs.

I looked for plugins, and the only thing I’ve found that is remotely close is JoomUnited, but it doesn’t restrict access to all folders except the one(s) you want, it just creates private folders for each user/role. Besides, I was hoping to use some kind of action hook to filter the folders shown in /wp-admin/upload.php, /wp-admin/media-new.php, and where ever else I may need to in order to get this functioning properly anyway.

, , , , Carri Dean 4 years 2020-05-26T19:10:41-05:00 0 Answers 91 views 0

Leave an answer