Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+9 votes
20.7k views
in Q2A Core by
If a user is not logged in, how do I hide all tabs (All Activity, Questions, Hot, unanswered, Tags, etc)?  I want to use this for work, but they wont let me do it unless I hide all questions and moderate users.  I get the moderations part, but I cannot find how to hide questions and all mentioned when no user is logged in.
Q2A version: 1.6.1
by
Hiding the links won't solve your problem. Anyone who had the page address would be able to see everything you're trying to hide.
by
moved by
Not necessairly hide, but if a user is not logged in, dont let them see questions.  When you click the question it prompts you to register or login - i want that at start, before even questions are displayed.
by
Roniaw is right, but it's easy to hide the content too. Eparisek ; you can use the code in my answer, and add code to redirect the viewer to the login page if he's not logged in.

1 Answer

+6 votes
by

There are many ways to do this. The better ways are probably (but I'm not an expert so maybe I'm wrong) these :

  • make a theme
  • make a layer plugin

If you know how to make these, you can use code along these lines : 

function doctype() {

    if(!isset(qa_get_logged_in_userid())) {

        unset($this->content['navigation']['sub']);

    } 

}

 

The above code would hide the subnavigation bar when the user is not logged in. It should get you going,  but you can always ask for more help.

by
Onurb, would it be possible to modify this so users can register, even if I have to provide the URL, actually, that would be the only preferred method.  I copied the Register URL and pasted it after authenticating, but it didnt like it.
by
Geez, a little faster next time, ROFL - you're too quick!!  Thank you.
by
:D haha! I noticed that the plugin can clash with other plugins (well it only clashes with my own plugins so far) - thought you'd like to know this, in case it stops working when you install other plugins.
by
I just registered to say thank you Bruno!
...