Restrict download page only to logged in pilots

how can i restrict access to my downloads page only to logged in pilots.

i tried this

<?php

if(!Auth::LoggedIn())

{

?>

<li><a href="<?php echo SITE_URL ?>/index.php/registration"><strong>Register</strong></a></li>
   <li><a href="<?php echo url('/login'); ?>"><strong>Pilot Log In</strong></a></li>

<?php

}

else

{

?>

<li><a href="<?php echo SITE_URL ?>/index.php/downloads"><strong>Downloads</strong></a></li>




<?php

but that doesnt work

how can i restrict access to my downloads page only to logged in pilots.

i tried this

<?php if(!Auth::LoggedIn()) { ?>
  • Register
  • Pilot Log In
  • <?php } else { ?>
  • Downloads
  • <?php but that doesnt work

    Switch the

    <li><a href="<?php echo SITE_URL ?>/index.php/registration"><strong>Register</strong></a></li>
    <li><a href="<?php echo url('/login'); ?>"><strong>Pilot Log In</strong></a></li>
    

    With the

    <li><a href="<?php echo SITE_URL ?>/index.php/downloads"><strong>Downloads</strong></a></li>
    

    ?

    Just add this at the top of that tpl,

    <?php
    if(Auth::LoggedIn() == false)
    {
      echo 'Please login to view this page.';
      return;
    }
    ?>
    

    You can also hide in the nav bar by putting the line under the section if logged in.

    is there a way to prevent access to the index page. specifically the downloads. i tried to add .zip tothe htaccess file and that worked, but then when legitimate pilots tried to d/l the got the 404 error?

    Hi im not quite following what you need, that code above will prevent joe bloggs from accessing the downloads.

    In fact looking at my site the index page of the downloads should already be protected for logged in users already.

    Mark is right. Downloads page is, by default, only available to logged in users.

    Open up core/modules/Downloads/Downloads.php and check, it should look something like this:

    class Downloads extends CodonModule
    {
    
    public function index()
    {
    	if(!Auth::LoggedIn())
    	{
    		echo 'You must be logged in to access this page!';
    		return;
    	}
    
    	$this->set('allcategories', DownloadData::GetAllCategories());
    	$this->render('downloads_list.tpl');
    }
    

    And so on.