Private Media directory for each user

Hi All,

I was wondering if anyone has an idea how to achieve backend Media separation. Essentially, I want each user to have their private directory that nobody else (besides Owner) can see in both, back-end Media menu and Tailor’s media field.

The example structure would be:
Everyone has access to /public
Only User1 and Owner has access to /user1/*
Only User2 and Owner has access to /user2/*

Any ideas will be much appreciated!

you should be able to extend the media controller and filter the folders listing based on the user.

To add to Chris;

Looks like this below could work :

 \Media\Widgets\MediaManager::extend(function ($instance) {
            \Config::set('', ...);
            \Config::set('', ...);

Thank you both for the ideas! Will try to figure out how to extend the method properly, but my temporary solution does exactly what I’ve expected to see! It’ll most likely get overwritten once I update October, so that’s why I need to follow your ideas regardless of this working now; if someone is wondering I’ve edited the following file modules\media\widgets\MediaManager.php

method responsible for changing directories is called listFolderItems

I’ve adjusted it to lock lower level directories for anyone that is not me

protected function listFolderItems($folder, $filter, $sortBy)
        $filter = $filter !== self::FILTER_EVERYTHING ? $filter : null;

        $user = BackendAuth::getUser();
        $exploded_path = explode("/", $folder);

        if ($user->id != 1) {
            if($exploded_path[1] != $user->id)
                $folder = '/' . $user->id;

        return MediaLibrary::instance()->listFolderContents($folder, $sortBy, $filter);

Unfortunately, changing directories doesn’t seem to be an event, hence I can’t quite intercept the request that way.