Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+2 votes
652 views
in Q2A Core by
I have defined initially a category that can be visible by any person without being supposed to be logged in. Inside this category i have added 6 questions.
Then I have added other categories that can be visible only by the approved users of the forum.
Now, if I'm not logged in into the forum, and i will just go to the Questions tab i will see a blank page with the possibility to click on the second page. I'm clicking on the second page button and then i will see all my 6 questions there.

As of now I just have 2 pages of questions but if there will me bore questions added I will end up with the public questions on the 10-11-12-...-N page and all the pages before that one will be blank.

Is there a way to fix this issue? Can you please help me?

Q2A version: 1.8
Q2A version: 1.8
by
You have made custom changes to Q2A which you have not explained in detail (with code). It is hard to see how to fix the issue without that information.

I have explained how to properly make something similar to a "private" category in this underrated answer: http://www.question2answer.org/qa/54987?show=54988#a54988
by
edited by
Thank you for your reply.

Sorry, i have missed to mention that I have installed a plugin that i took from https://github.com/ProThoughts/permission2categories in order to be able to set permission for a category. And inside this plugin, in the p2c_layer.php file, i have added also "QA_USER_LEVEL_APPROVED  => 'Approved+',"

What i want to achieve is that when the user is not logged in to see only 6 questions in the Question list displayed on the first page of questions (now i see those 6 on the second page and the first page is empty)...but when the user is logged in to be able to see all existing questions in the forum.
The solution indicated by you, if i understood it correctly, will hide the questions from a category from the entire site forever, no matter if the user is logged in or not.

It seems the problem I raised here is also mentioned here https://github.com/kfuchs/permission2categories/issues/5 and it doesn't seem to be solved :( .
by
edited by
I have managed to fix it :) . Thanks again for your reply.
I have used your answer from  http://www.question2answer.org/qa/54987?show=54988#a54988 and i just added a condition if the user is logged in or not.

Below is the code i have used in selects.php into the qa_db_qs_selectspec function:

    if (qa_is_logged_in() && qa_get_logged_in_level() >= QA_USER_LEVEL_APPROVED) {
        $selectspec = qa_db_posts_basic_selectspec($voteuserid, $full);

        $selectspec['source'] .=
            " JOIN (SELECT postid FROM ^posts WHERE " .
            qa_db_categoryslugs_sql_args($categoryslugs, $selectspec['arguments']) .
            (isset($createip) ? "createip=UNHEX($) AND " : "") .
            "type=$ " . $sortsql . " LIMIT #,#) y ON ^posts.postid=y.postid";
    } else {
        $selectspec = qa_db_posts_basic_selectspec($voteuserid, $full);
       
        $hiddenCategoryIds = array(1, 2, 3, 4, 5, 6);
        $hideInPages = array('', 'activity', 'questions');
        if (in_array(qa_request(), $hideInPages) && !empty($hiddenCategoryIds)) {
            $sql = '(^posts.categoryid NOT IN (' . implode(',', $hiddenCategoryIds) . ') OR ^posts.categoryid IS NULL) AND ';
        } else {
            $sql = '';
        }
        $selectspec['source'] .= " JOIN (SELECT postid FROM ^posts WHERE " .
                $sql.
            qa_db_categoryslugs_sql_args($categoryslugs, $selectspec['arguments']) .
            (isset($createip) ? "createip=UNHEX($) AND " : "") .
            "type=$ " . $sortsql . " LIMIT #,#) y ON ^posts.postid=y.postid";
    }
by
Nice, thanks a lot for the answer
by
I updated the answer in order to replace " if (qa_is_logged_in())" with "if (qa_is_logged_in() && qa_get_logged_in_level() >= QA_USER_LEVEL_APPROVED)" because it seems the question list was not displayed correctly if a new user was not yet approved.
by
it seems i have same problem in the HOT page :( . Can somebody tell me what i should change and how to it in order to correctly display also there the questions?

Please log in or register to answer this question.

...