Is there a way to allow guests to read posts in a specific forum but not be able to download attachments? I have a tutorial forum that will have tutorials in .pdf format and I want everyone to be able to read the posts in that forum but only allow registered users to download the .pdf files.
Lainaus käyttäjältä: VE3JOC - huhtikuu 18, 2020, 12:43:07 IP
Is there a way to allow guests to read posts in a specific forum but not be able to download attachments? I have a tutorial forum that will have tutorials in .pdf format and I want everyone to be able to read the posts in that forum but only allow registered users to download the .pdf files.
Yes, you can do that at the board permissions page. Untick View attachments permission set.
Also I have a mod that adds a permission for downloads/view
So you can see their are attachments in the post but not allow downloads
https://custom.simplemachines.org/mods/index.php?mod=4189
Thanks vbgamer45. If this mod was installed, where would you go in the admin to limit the downloading of attachments?
It is a membergroup level permissions. So under permissions for each membergroup
Ok, I tried it. I checked the View Attachments and unchecked the Download attachments but when I log in as a guest I cannot see any attachments. Maybe I am not understanding how it works but my impression was that they could see that there is a file attached but not be able to download it.
Thanks
That's what it should do. Using a custom theme or default theme?
I have a custom theme.
Want to double check you made the change for guest group as well?
If you did attach your display.template.php file for your theme.
The only display.template.php file that I can find is in the default theme. I have attached it.
Just confirming you gave the guests membergroup the "View Attachments " permission
Yes,... I did that.
Still can't get it to work properly.
Can't get it to work properly so I uninstalled it. Guess I'll have to see if I can find another way of doing this.
Thanks anyway.
Lainaus käyttäjältä: VE3JOC - huhtikuu 18, 2020, 02:09:08 IP
Ok, I tried it. I checked the View Attachments and unchecked the Download attachments but when I log in as a guest I cannot see any attachments. Maybe I am not understanding how it works but my impression was that they could see that there is a file attached but not be able to download it.
Thanks
I thought 'Guests' were people who were
not logged in! :P
this will show the attachments, but they aren't available for download.
Lainaaedited to add: you MUST have attachments visible to guests in your forum's permissions for this to work
first off, if you're using a custom theme or theme OTHER than default, and that theme DOES NOT have a Display.template, COPY the Display.template from your default file and paste it to the theme you are using's directory- leaving the virgin copy behind in default theme... this will retain a virgin copy of your Default.template if you choose to get rid of this code/function...
open the Display/template you just made (or the default one if you're using the default theme)
find:
echo '
<a href="' . $attachment['href'] . '"><img src="' . $settings['images_url'] . '/icons/clip.gif" align="middle" alt="*" /> ' . $attachment['name'] . '</a> ';
it should be around or on line 530 of 2.0.17's virgin Default.template....
replace it with:
// code inject for only members able to download attachments
if ($context['user']['is_guest'])
echo '
<a href="' . $scripturl . '?action=login">Login</a> or <a href="' . $scripturl . '?action=register">Register</a> to download attachment.
';
elseif ($context['user']['is_logged'])
echo'
<a href="' . $attachment['href'] . '"><img src="' . $settings['images_url'] . '/icons/clip.gif" align="middle" alt="*" /> ' . $attachment['name'] . ' click to download</a> <br /> ';
// end inject for members only attachments download.
that's pretty much all there is to it... it doesn't have a back-end admin control, obviously, so... the code will have to be removed to revert back... folks around here don't like their code being hacked, so don't expect this to be popular.
Thanks drewactual. I have "allow viewing of attachments" checked but having inserted the code the attachment is only visible to logged-in users. Guests do not see that attachment.
There USED to be a server side apache rpm that would open Microsoft and Adobe files on webpages... it was a resource hungry thing, but it worked. To my knowledge and without massive amounts of coding and IF that rpm was adaptable, I still think it would be near impossible to have a working "view" documents... an image? All day long... a file? Different animal...
The code I offered will at least show there is an attachment to a guest, and will allow an image to be seen but not downloaded.
Thanks drewactual. No problem. As long as users know that there is a tutorial that they can download if they log-in, that's great.
Thanks again.