How to change Default Access Control on File Upload to Group?


I'd like to have Groups as the Default Access Selection on File Upload Form in Groups.

I use the File Upload Function only in Groups.

i have modified the file plugin at /file/lib/file.php. 

'access_id' => in  function file_prepare_form_vars (line 20).

Setting the access_id => to the group ID (e.g. 'access_id' => 5,) works fine. But each Group has a different ID. So i need a general Solution.

Thanks for your Time!

  • You are not supposed to modify an elgg core file. All modifications should be written in plugins. Access_id = 5 can be different for different users. If you want to set a group as the default access for your users, you need to

    • Create a plugin hook for the user registration, so that all the users will become members of a group by default
    • Donot allow users to leave that particular group. create a hook for the user leave action and return false if the group guid matches this exclusive group
    • Set the site default access as this group and donot allow user default access level OR
    • override the file upload form viewwith your own form view in which access is set as a hidden value.
  • Thanks for your answer. I know i shouldnt change the core files und always use plugins. 

    I tried this way just for testing because i couldnt find another solution.

    Maybe i have expressed myself wrong. I dont want to set a group as the default access for my users. I just want to have in any Group Related Forms, where you can upload files or create something, like File Upload,make Announcements etc. that the Access Dropdown Box which contains Public, Privat, Logged In Users and Group:Name of the Group always shows the Group:Name of the Group as the default selection when opening such a form to create something.The standard selection in most plugins is private or public.

    So my problem is a) to find the place in the plugins where to set the default selection for Access in forms and b) i know to set 0,1,2 for private, public and logged in users, but not the expression to get always the right group id.

    Thanks for your help!