Skip Navigation

[Resolved] Only allow logged in users to download files.

This thread is resolved. Here is a description of the problem and solution.

Problem:

I am creating a website that allows users to upload resources for other users to download. In the (resource) content template, I would like to allow logged out users to be able to view the available resources but the files should only be downloadable by logged users.

Solution:

You can use Views shortcode [wpv-conditional] to check if current user is a logged in user, for example:

[wpv-conditional if="('[wpv-current-user info='id']' eq '')"]
Non logged in users
[/wpv-conditional]
 
[wpv-conditional evaluate="false" if="('[wpv-current-user info='id']' eq '')"]
Logged in users, display only the download file link.
[/wpv-conditional]

Relevant Documentation:

https://toolset.com/documentation/user-guides/conditional-html-output-in-views/

Conditional HTML Output in Views

This support ticket is created 6 years, 1 month ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 4 replies, has 2 voices.

Last updated by imaneK 6 years ago.

Assisted by: Luo Yang.

Author
Posts
#614420
Content template.png

Hi there,

I am creating a website that allows users to upload resources for other users to download. In the (resource) content template, I would like to allow logged out users to be able to view the available resources but the files should only be downloadable by logged users.

Please let me know if further clarifications are needed.

Thank you.

#614511

Hi,

You can use Views shortcode [wpv-conditional] to check if current user is a logged in user, for example:

[wpv-conditional if="('[wpv-current-user info='id']' eq '')"]
Non logged in users, display only the download file title
[/wpv-conditional]

[wpv-conditional evaluate="false" if="('[wpv-current-user info='id']' eq '')"]
Logged in users, display only the download file link.
[/wpv-conditional]

More help:
Conditional HTML Output in Views
https://toolset.com/documentation/user-guides/conditional-html-output-in-views/

#622200
Capture6.PNG
Capture5.PNG
Capture4.PNG
Capture3.PNG

Hi,

Sorry for the late reply,

I am already using short code to display the uploaded resources( as seen in screenshots). So, I'm not to sure how to integrate both together. Would you be able to provide further support on the matter.

Thank you very much.

#622374

I assume the original question of this thread has been resolved:
https://toolset.com/forums/topic/only-allow-logged-in-users-to-download-files/#post-614420

For the new question:
I'm not to sure how to integrate both together.

Please create new thread for the new question, that will help other users to find the answers.

#622431

OK, thank you.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.