Jump to content

roles and access? hide from guest/member...


bwakad
 Share

Recommended Posts

I have added a role named TESTER, and a user named TEST.

My login(.php) template and page is ready but I want this only visible in menu if viewer is guest.

The login - page role says: guest (everyone) - view (and of course superuser) but no tester!

The login - template says : guest, tester, and superuser. The checkbox for tester cannot be unchecked...?

The access > roles > tester : is (for now) set to view and update password.

The access > users > test : is set to guest and tester. I cannot uncheck the guest (is required warning)...?

I guess the guest is required by all roles one creates. My question is, do I have to do something in the backend to (based on roles) hide a page from the menu, or is there something wrong with my setup, or is there another way to do this?

I hope someone can tell me what to do...

Link to comment
Share on other sites

I did it by isLoggedIn(), which is much easier to read. So in my foreach loop I use this code:

foreach($children as $child) {
        $class = $child === $page->rootParent ? " class='active'" : '';

        if ($user->isLoggedIn()) {  // is member?
               if ($child->name == "login") {  
                   // skip login page if logged in
                   continue ; 
               }
        } else {  // is guest !             
               if ($child->name == "profile" OR $child->name == "logout") { 
                   // skip profile OR logout page if logged out
                   continue; 
               }
         }            
         echo    "<li $class><a href='{$child->url}'>{$child->title}</a></li>"; 
}

Then I would think I also have to give some kind of statement in top of page, something like direct acces not allowed if one would enter it in the browser url?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...