How to Hide the Download Button for the Public User Group in OSDownloads

In some use cases, you may want to hide the "Download" button of your OSDownload file from non-logged visitors to your Joomla site.

You can achieve this with the "Conditional Content" component from the team RegularLabs.com and the Joomla core component "Template Overrides".

  • Download, install and enable the Free version of the "Conditional Content" component from the team RegularLabs.com.
  • Go to System > Site Templates.
  • You will see the "Templates: Templates (Site)" admin page listing your front-end template(s). Click on the title of your active front-end template.
  • You will arrive at the "Templates: Customise (<name-of-your-template>)" admin page. Click the "Create Overrides" tab:

the create overrides tab

  • In the "Components" column, click com_osdownloads > item:

the item link

  • You will see the "Override created in /templates/<name-of-your-template/html/com_osdownloads/item" message, as shown in the next image. Click the "Editor" tab:

the message and the editor tab

  • Click html > com_osdownloads > item > default.php:

the default PHP file

  • You will see the default.php file open. Find the following line of code:
 <div class="btn_download">

the code to find

  • Place under this line of code the following code snippet:
{show accesslevels="Registered"}

the code to add

  • Underneath the next line, add the following code:
   {/show}
  • Now, your whole code snippet should look as follows:
 <div class="btn_download">
          {show accesslevels="Registered"}
            <?php echo LayoutHelper::render('osdownloads.buttons.download', $this); ?>
          {/show}
</div>

How to Hide the Download Button for the Public User Group in OSDownloads

  • Click Save or Save & Close.
  • Test your downloadable files at the front of your site. You will see that they don't display the "Download" button.
  • Log in to your site front. You will now see the "Download" button displayed.