Is it possible for each user to have their own folders?
Can we configure my WordPress media folders plugin so each user has access only to their own folders?
Of course, we can do that, and all you need to do is use the filter hook that appeared in the 4.0.1 plugin version, which is smlf_folders_taxonomy_base. In simple words, we are going to modify the taxonomy name used for media folders, and we’ll add a user ID to it.
You need to use the following code snippet on your website:
add_filter( 'smlf_folders_taxonomy_base', function( $taxonomy_base ) {
if( is_user_logged_in() ) {
$taxonomy_base = $taxonomy_base . '_' . get_current_user_id();
}
return $taxonomy_base;
}, 25 );That’s pretty much it. If you don’t know where to add this code snippet, please check this.
Unique media folders for each user of a specific role
What if you don’t want to allow unique media folders for every user, but only for users who have a specific user role on the website? It is also possible to achieve with the same filter hook.
add_filter( 'smlf_folders_taxonomy_base', function( $taxonomy_base ) {
if( current_user_can( 'editor' ) ) {
$taxonomy_base = $taxonomy_base . '_' . get_current_user_id();
}
return $taxonomy_base;
}, 25 );Shared media folders for a specific user role
On the other hand, if you want users who have a specific role on the website to manage the same list of media folders, then your code snippet is going to look like this:
add_filter( 'smlf_folders_taxonomy_base', function( $taxonomy_base ) {
$role = 'editor';
if( current_user_can( $role ) ) {
$taxonomy_base = $taxonomy_base . '_' . $role;
}
return $taxonomy_base;
}, 25 );