Must be logged in to access

HI Nabeel, Dave and Jeff

Is there a code snipped to add to the page to make it that you must be logged to to view or access?

I would like to make the pilots list only viewable by members.

Cheers.

core_navigation.tpl

  • Home
  • <?php if(!Auth::LoggedIn()) { // Show these if they haven't logged in yet ?> <?php } else { // Show these items only if they are logged in ?>
  • Pilots
  • //Place the Pilots link here <?php } ?> <?php echo $MODULE_NAV_INC;?> <?php if(Auth::LoggedIn()) { if(PilotGroups::group_has_perm(Auth::$usergroups, ACCESS_ADMIN)) { echo '
  • Admin Center
  • '; } ?>
  • Log Out
  • <?php } ?>

    Hi Jeff,

    Thanks for that but i have that already, if someone hits the pilots list directly it will still show them, what im after is like the Airmail feature if you try to access that you get a redirect to you must be logged in to access this page etc.

    is the pilots page listed in here as well?

    <li><a href="<?php echo url('/'); ?>">Home</a></li>
    <?php
    if(!Auth::LoggedIn())
    {
           // Show these if they haven't logged in yet
    ?>
    
    <?php
    }
    else
    

    it shouldn’t be showing if it isn’t, unless I missed something. Let me do a little more searching for you.

    Ah crap. nm on the last post the “Show if logged in” is just the code to show a certain page on the menu. Still looking for you though.

    What you need to do is add the entire sheet into the brackets of this

    <?php if(Auth::LoggedIn()) {?>

    //Put the entire sheet here

    <?php } else { echo "You must be logged in to view this page"; } ?>

    Cheers Jeff Thats the one

    Thanks Jeff, I knew I was close.

    If you don’t mind me saying, it’s better to do this:

    <?php
    if(Auth::LoggedIn() == false)
    {
      echo 'You must be logged in to view this page!';
      return;
    }
    ?>
    

    No else or other brackets to keep track of

    That would explain the repeat in some pages that “You must be logged in to view this page”

    Cheers guys.

    Still the same repeat on the pilots list,

    This is what im using then its pulling the error formatting from the css.

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

    That extra closing div is only relevant on the ObsessBlue templates

    Just quickly going back to this Nabeel if i use your way i get a repeat of the login message for the amount of hubs that i have but if i place the page in the brackets that fixes it, is their another way?

    Ah got you. Cheers Jeff.