Jump to content

Limit download to premium users


phseven

Recommended Posts

Yes, it is possible but not via settings, but via template.

In Website UI -> Pages -> View Video page -> video_view block template there is the following code to render download links:

{{foreach item="item" from=$data.download_formats}}
		{{assign var="format_lang_key" value=$item.postfix|replace:".":"_"}}
		<a href="{{$item.file_url}}" data-attach-session="{{$session_name}}">{{$lang.videos.video_details_label_download_format[$format_lang_key]|default:"%1%, %2%"|replace:"%1%":"`$item.title`"|replace:"%2%":$item.file_size_string}}</a>
{{/foreach}}

 

What you should do is change this:

href="{{$item.file_url}}"

with this:

{{if $smarty.session.status_id==3}}href="{{$item.file_url}}"{{elseif $smarty.session.user_id>0}}href="{{$lang.urls.upgrade}}" data-fancybox="ajax"{{else}}href="{{$lang.urls.login_required}}" data-fancybox="ajax"{{/if}}

 

So KVS will still display download links, but if non-premium user clicks this link there will be either login dialog (user is not logged in), or upgrade dialog (user is not premium status) displayed.

  • Like 3
Link to comment
Share on other sites

Hi, it didn't work for me.

here's my snippet

{{foreach item="item" from=$data.download_formats}}
										{{assign var="format_lang_key" value=$item.postfix|replace:".":"_"}}
										<a href="{{$item.file_url}}&download_filename=mysite_{{$data.dir}}{{$item.postfix}}" data-attach-session="{{$session_name}}">{{$lang.videos.video_details_label_download_format[$format_lang_key]|default:"%1%, %2%"|replace:"%1%":"`$item.title`"|replace:"%2%":$item.file_size_string}}</a>
									{{/foreach}}

 

Link to comment
Share on other sites

25 minutes ago, Emilia said:

Yes, can you tell me where to put it? It broke when i did it

Here:

<a {{if $smarty.session.user_id>0}}href="{{$item.file_url}}&download_filename=mysite_{{$data.dir}}{{$item.postfix}}"{{else}}href="{{$lang.urls.login_required}}" data-fancybox="ajax"{{/if}} data-attach-session="{{$session_name}}">{{$lang.videos.video_details_label_download_format[$format_lang_key]|default:"%1%, %2%"|replace:"%1%":"`$item.title`"|replace:"%2%":$item.file_size_string}}</a>

Should not brake anything.

  • Like 1
  • Thanks 1
Link to comment
Share on other sites

  • 2 years later...
On 1/29/2021 at 12:36 PM, Tech Support said:

Yes, it is possible but not via settings, but via template.

In Website UI -> Pages -> View Video page -> video_view block template there is the following code to render download links:

{{foreach item="item" from=$data.download_formats}}
		{{assign var="format_lang_key" value=$item.postfix|replace:".":"_"}}
		<a href="{{$item.file_url}}" data-attach-session="{{$session_name}}">{{$lang.videos.video_details_label_download_format[$format_lang_key]|default:"%1%, %2%"|replace:"%1%":"`$item.title`"|replace:"%2%":$item.file_size_string}}</a>
{{/foreach}}

 

What you should do is change this:

href="{{$item.file_url}}"

with this:

{{if $smarty.session.status_id==3}}href="{{$item.file_url}}"{{elseif $smarty.session.user_id>0}}href="{{$lang.urls.upgrade}}" data-fancybox="ajax"{{else}}href="{{$lang.urls.login_required}}" data-fancybox="ajax"{{/if}}

 

So KVS will still display download links, but if non-premium user clicks this link there will be either login dialog (user is not logged in), or upgrade dialog (user is not premium status) displayed.

Luckily I found this topic, I was intend to create a new topic to ask exactly like this topic, how to enable download to only logged in members, thank you

Link to comment
Share on other sites

May I ask what's the difference between:

{{if $smarty.session.user_id>0}}href="{{$item.file_url}}"{{else}}href="{{$lang.urls.login_required}}" data-fancybox="ajax"{{/if}}

And

<a {{if $smarty.session.user_id>0}}href="{{$item.file_url}}&download_filename=mysite_{{$data.dir}}{{$item.postfix}}"{{else}}href="{{$lang.urls.login_required}}" data-fancybox="ajax"{{/if}} data-attach-session="{{$session_name}}">{{$lang.videos.video_details_label_download_format[$format_lang_key]|default:"%1%, %2%"|replace:"%1%":"`$item.title`"|replace:"%2%":$item.file_size_string}}</a>

Which one should I use or is it the same?

Link to comment
Share on other sites

3 hours ago, Tanjiro said:

May I ask what's the difference between:

The 2nd one adds download filename parameter which looks like this:

&download_filename=mysite_{{$data.dir}}{{$item.postfix}}

You can use it, but worth changing "mysite" to your site name. Then the downloaded video file will have mysite_video-name.mp4 filename.

  • Like 1
Link to comment
Share on other sites

  • 6 months later...
On 1/29/2021 at 7:32 PM, Tech Support said:

 

Should be:

{{if $smarty.session.user_id>0}}href="{{$item.file_url}}"{{else}}href="{{$lang.urls.login_required}}" data-fancybox="ajax"{{/if}}

 

where i put this code?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...