by Luis de la Torre.
Hi! I finally learnt how to do it.
It wasnt that difficult, actually. Although it took me several hours
Basically, you just have to do what Tim said in the _pluginfile funtion: control if the users should have access to the file or not and (this part wasnt mentioned by Tim), if they should, then call send_stored_file().
My problem was of a different kind. During my tests I changed the component field in the file table of the database and so, for each test I carried out, the result was always: "Error, file not found". This happens because send_stored_file() checks if the pathname for each file (see the example posted by Marinko) corresponds to its coded value in the pathnamehash field of the file table.