Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+7 votes
4.3k views
in Q2A Core by
There are 4 categories in my website and I wanna make one of them only visible to logged in users.

Or if it makes it simple, at least the question page of questions of that category only visible to logged users. That measn all questions to be listed at question lists but when click on the question of that category it only gets displayed to logged users ( and ofcourse to be hidden to google indexers)
Q2A version: 1.6.2

3 Answers

+2 votes
by
selected by
 
Best answer

This is good idea. I have done some quck coding for you :)

I have tested and it is working fine with Snow theme. You may need to get categoryname or categoryid dynamically or set it static in conditon.

Copy provided code into your theme or plugin layer file.

Change The first child in conditin with your category

Due to character limit here find code on gist here https://gist.github.com/q2amarket/8258201

by
Thank you very much Jatin
by
You are welcome.. just let me know how this code works for you and if possible post updated code so other people also can refer and use for the same.
by
Sure, but I havent tested it yet. I will do and let you know :)
by
Hi Jatin,
It worked like a charm. We just have to remember when using category id that
$content['q_view']['raw']['categoryid'] is a string not an integer number. Therefor for a categury id of 2, we set up the condition like this:

if((@$content['q_view']['raw']['categoryid'] !== '2'

Thank you
by
I think if you have multiple IDs than you can set in array and than check with in_array() that might work for multiple categories. However I haven't check this. If will get some free time than will try to make a plugin.

Did you tried other plugin from kfuchs.. ? because I believe it would be great if you can get it as a plugin and not hard coded. I haven't get chance to dig in it but will see later..

Let me know if you get something new with related query...
by
Yes it would be great to have a plugin ..... :-)
by
I just tested the kfuchs plugin whose aim is to set the visibility of categories to Anyone or Experts ... Super Admin. But if I am not mistaken, it only disappears the list of questions of the category made visible. That means if you know the url of that catgegory yet dont have permission will still be able to see the question posted in that category.
In brief: kfuchs is not good
by
Hi  I am interested in this too. So you said you tested Jatin.Soni solution but it did not help?
0 votes
by
edited by

This plugin may be near your hope. Code level is high and can trust it.

https://github.com/kfuchs/permission2categories

Reference thread:

http://www.question2answer.org/qa/29188/admin-only-categories

However, it may be necessary to make some modifications.

by
Oh I didn't know.. I am taking my vote back. :P kidding..
Than you can try my code if it works for you..
by
Thank you sama55, could please you also comment here whether there is any issue with your plugin.
Thank you guys,
by
1. It is not essential, but is necessary to add QA_USER_LEVEL_APPROVED to $permitoptions of p2c_layer.php.

2. I feel if plugin use Q2A API functions for permission feature, plugin will be more better.
    qa-app-admin.php::qa_admin_permit_options()
    qa-app-users.php::qa_user_permit_error() / qa_permit_error() / qa_permit_value_error()

maxjtechno will have much information about the real use issue than me.
by
Sorry guys I mistakenly posted my comment as an answer! I just wanted to say this plugin would be very helpful and takes the QA to a whole new level
+1 vote
by
You know what! I just gor an awesome idea! Using jatin's plugin/ solution we can give the prvilage to only users with score of at least x! That would encourage users to contribute more into the contents of your QA website!  cuz they wanna get that minimum score to be able to see contents of questions posted at that category!!
by
+1 Wonderful idea.. okay let me try to make a plugin which allows to limit access by loggein, userid and point specific users.
by
That would be great jatin! Thank you.
by
A plugin would be Awesome jatin thank you for all effort ( and thank you Armin for the idea)
by
@Water I didnot do anything, all the hardwork will be done by jatin.
by
is this plugin available yet!!
...