How to force users to log in to download files?

It doesn't seem elgg offers that option, in other words, the person can see there is a link and a description in there, but he needs to loggin, if he wants to download it.

Is there a pluggin that can do that?

  • if(isloggedin()){

    echo "<div>do logged in stuff</div>"

    }else{

    echo "<div>do something different</div>"

    }

  • Elgg has privacy for that I think. Public, private and friends. If the file is public, anyone will be able to download it. If the file is for friends, well, only friends will be able to download it.

    Rodolfo Hernandez
    Arvixe/Elgg Community Liaison

  • well rjcalifornia, elgg has it but, why would the visitor need become friends with the person just to download a file? : )

    And when limit access to only loggedin users, elgg will just hidde the content, I cant hide it.

  • In that case you have to create a separate access input for files plugin and set the value to public. And wrap your download button with in an if(isloggedin()) condition.

  • I thought I just stated that yesterday?

  • Peter M

    ahhh ha! we here thinks that you did 'stated so..' ;)

  • If you want to force ALL files to be accesible only for logged in users and to don't matter if the downloader is friend with the owner of the file, just go to "mod/file/actions/file/upload.php" and look for $access_id variable:

    // Get variables
    $title = get_input("title");
    $desc = get_input("description");
    $access_id = (int) get_input("access_id");

     

    and change its value for 1 (1 = logged in users, 0 = Private, 2 = Public, -2 = Friends):

    // Get variables
    $title = get_input("title");
    $desc = get_input("description");
    $access_id = 1;

     

    and since now all the files uploaded will be only accesible to logged in users.

    Test it and tell us if it solves your problem ;)

  • But, it doesnt seem that option will show the file, I mean, the user must know there is a file in there, but he's got to login, otherwise, neither search engines gonna be able to see there is a page content.

  • This is draggging tooo longgg ;-P The code's gotta be q. simple -- somewhere... inside there - Whether hard-coded in the Files PlugIn itself or a Custom PlugIn to extend views and control the links' URLs, titles, prompts, HREFs.. It just might take some little bit of coding. However -- I do beleive that almost any imaginabable wanted feature such as this - *can be coded using Elgg's API and maybe some PHP`ese along the way.

  • ok do the same but instead of 1 set the variable to 2 (public), and go to /mod/file/pages/file/download.php

    and insert this code at the beggining:

    if(!elgg_is_logged_in()){

    register_error("You need to log in in order to download...");

    forward();

    }

     

    Hope that this will resolve your problem.