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.

  • Thanks 1
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...