How to restrict download in media player plugin to Premium

halalrizik2841

New Member
YetiShare User
Aug 5, 2013
40
0
0
Hi,

How can i restrict download for free users in media player plug in. If i restrict downloads in website settings, it restricts everything. I want to display the download button and the media player, but when a free user clicks on the download button, it should redirect to premium upgrade page.

How do i do it, can we do it with if else loop?

Thanks.
 

ysmods

New Member
Jan 29, 2013
860
1
0
UK
www.ysmods.com
Re: How to restrict download in media player plugin to Premi

This will work for v3.3+

The modified code will allow the admin and paid users to download as normal, but free users will be shown the upgrade page in a new window (keeping the original page open should they upgrade their account and want to download the file.).

Open up "/plugins/mediaplayer/includes/_append_file_download_bottom.php"

Find:
Code:
<?php echo safeOutputToScreen($file->originalFilename); ?>&nbsp;&nbsp;
<?php if ((int) $pluginSettings['show_download_link'] == 1): ?>
	<a href="<?php echo $file->getFullShortUrl(); ?>?df=1&dt=<?php echo $embedToken; ?>" target="_blank">(<?php echo t('download', 'download'); ?>)</a>
<?php endif; ?>
Replace with:
Code:
<?php echo safeOutputToScreen($file->originalFilename); ?>&nbsp;&nbsp;
<?php if ((int) $pluginSettings['show_download_link'] == 1): ?>
<?php 
if ($Auth->level == 'free user')
{
	echo '<a href="'.getCoreSitePath().'/upgrade.'.SITE_CONFIG_PAGE_EXTENSION.'" target="_blank">('.t("download", "download").')</a>';
}
else
{
	echo '<a href="'.$file->getFullShortUrl().'?df=1&dt='.$embedToken.'" target="_blank">('.t("download", "download").')</a>';
} 
?>
<?php endif; ?>
 

halalrizik2841

New Member
YetiShare User
Aug 5, 2013
40
0
0
Re: How to restrict download in media player plugin to Premi

So how do we do this in version 3.5?

Thanks.
 

neil3834

New Member
YetiShare User
Apr 10, 2014
57
0
0
Re: How to restrict download in media player plugin to Premi

Open upthe file and look for similar code.
Compare the code snippet and find what needs to be updated!

Re-read his response if you are unclear.

halalrizik2841 said:
So how do we do this in version 3.5?

Thanks.
 

ysmods

New Member
Jan 29, 2013
860
1
0
UK
www.ysmods.com
Re: How to restrict download in media player plugin to Premi

Try this

Code:
<?php echo safeOutputToScreen($file->originalFilename); ?>&nbsp;&nbsp;
<?php if ((int) $pluginSettings['show_download_link'] == 1): ?>
<?php 
if ($Auth->hasAccessLevel(2))
{
   echo '<a href="'.getCoreSitePath().'/upgrade.'.SITE_CONFIG_PAGE_EXTENSION.'" target="_blank">('.t("download", "download").')</a>';
}
else
{
   echo '<a href="'.$file->getFullShortUrl().'?df=1&dt='.$embedToken.'" target="_blank">('.t("download", "download").')</a>';
} 
?>
<?php endif; ?>