Topic: Permissions for Navigation

I'm not sure if this is the right place, or if this has been done, I checked.. but I'm wondering as to how can I have links in the navigation invisible to guests, and viewable for users? I have a few custom links added using the settings in the admin panel, and I would like a few of them to be hidden to the public but registered users. Any help would be very appreciated tongue. Sorry again if this is the wrong forum to post in.

Re: Permissions for Navigation

Navigation links are generated in the function "generate_navlinks" (Line 413 of "<FORUM_ROOT>/include/functions.php"). Additional navlinks are added at lines 458-464. To determine whether a user is guest or not use this code:

  if ($forum_user['is_guest'])
  {
     //actions
  }

Will this information be enough for you?

Re: Permissions for Navigation

Yes! Thank you so much! smile

4

Re: Permissions for Navigation

Thanks to ALL for the generous gift of your genius. I am in over my head but I am having fun. I would like to exclude the optional navigation links from guest viewing and I have attempted the solution from Slavok but this is the best I can do:

    // Are there any additional navlinks we should insert into the array before imploding it?
    if ($forum_user['is_guest'] = false)
    {if ($forum_config['o_additional_navlinks'] != '' && preg_match_all('#([0-9]+)\s*=\s*(.*?)\n#s', $forum_config['o_additional_navlinks']."\n", $extra_links))
    {
        // Insert any additional links into the $links array (at the correct index)
        $num_links = count($extra_links[1]);
        for ($i = 0; $i < $num_links; ++$i)
            array_insert($links, (int)$extra_links[1][$i], '<li id="navextra'.($i + 1).'">'.$extra_links[2][$i].'</li>');
    }}

Is it my syntax or am I too green to be going here? At the least, I do not know how to write the

if ($forum_user['is_guest'] = false)

argument.

Re: Permissions for Navigation

The 458 line of "<FORUM_ROOT>/include/functions.php" will look like:

if (!$forum_user['is_guest'] && $forum_config['o_additional_navlinks'] != '' && preg_match_all('#([0-9]+)\s*=\s*(.*?)\n#s', $forum_config['o_additional_navlinks']."\n", $extra_links))

6

Re: Permissions for Navigation

Thanks, Slavok. It worked! I over complicated matters.