Only admin can upload files

Hi

First post! I was hoping I could get through Elgg without having to make one! 

I've spent a good 5hrs this evening trying to get to grips with restricting File uploads to Admins only. I managed to find the "Gatekeeper" workaround for creating pages, but I'm not having any joy with the files. 

I need the facility to be able to stop users uploading files of any description and for this facility just to be made available to the admin. I'm not too fussed about it looking pretty and removing the upload / zip boxes - I just need to stop them from actually doing it. 

Hope somebody can take the time to help me, My Elgg installation depends on this and I've come so far, this is my last issue before I can go live. 

Thanks in advance, 

Maritn

  • Hi - Just picking up an old thread - can one do this AND remove the upload button for all except admin?

  • Thanks Matt.

    I've found this (below) in the \mod\file folder but cannot work out what I need to do to

    a) get rid of the upload a file button for anyone but admin, or at least

    b) make it so no-one other than admin can USE the upload a file button.

    Please could you help a little futher? Thank you

    // Register actions
     $action_path = elgg_get_plugins_path() . 'file/actions/file';
     elgg_register_action("file/upload", "$action_path/upload.php");
     elgg_register_action("file/delete", "$action_path/delete.php");

  • Yeay - I think I worked it out!

    I went to file\pages\file and changed the below....pls can you confirm that this looks ok from a coding/security POV? Thanks so much.

    gatekeeper();
    group_gatekeeper();

    to

    gatekeeper();
    admin_gatekeeper();

  • It's fine, but you've still not followed my advice about not hacking the core files.  You'll lose it all if you ever try to upgrade.

  • Thanks Matt - would you please help me by explaining a little more what you meant by :

     http://blog.elgg.org/pg/blog/cash/read/171/

     You want to hook into 'register', 'menu:title'

    I really appreciate the help - but am not sure what to do with it. I cannot find 'menu:title'.

    P

  • in start.php of your custom plugin

    elgg_register_plugin_hook_handler('register', 'menu:title', 'myplugin_title_menu');

     

    function myplugin_title_menu($hook, $type, $return, $params) {

    // here you want to put your logic

    // menu items are stored in the array $return

    // identify the menu item you want to restrict and unset it if not admin

    return $return;

    }

  • Hi,

    I am not expert in coding.

    I Need a Plugin to Control File Format (mp3 for Example) and Only admin can upload files. anybody know How can I do this?