Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+2 votes
374 views
in Plugins by
I would like one specific category in which the member who started the question is the only member allowed to answer, and other members can only comment on the answers.

For example, in psuedo-ish:

If categoryID = 16 and current visitor/member is not the member who started the question, hide the Answer button/link/message box and hide/disable the select best answer option.

Is this something I could do through a simple hack in the template or does it require a plugin?
by
Ok, I managed to make some progress myself.

In the theme base file I added a check for the category ID before it outputs the 'answer' button. I also used qa_get_loggedin_userid() to get the current user ID. I need one more step, and that is comparing the logged in user id to the author's ID. In particular the author of the original question. Is there a var or function I can use to retrieve it, qa_get_question_author_userid() or something :)  

I noticed the $post['who']['data'], but don't know if that's the way to go and if so how to retrieve the user ID specifically for the question's author.

1 Answer

0 votes
by
 
Best answer
Not getting answers has been very helpful so far. Getting to know the code much better this way :)

Ok, so the userid is part of the $post, which is $q_view in the relevant functions, but isn't passed on through to the form functions. The form functions create the buttons, so I've added the following to post_meta_who

$this->authorid = $post['raw']['userid'];

And then later when the buttons are rendered I compared it to the logged on ID.

I.o.w I added an authorid var to the qa_html_theme_base class, which feels a bit like overkill, but, it works. Might as well go all the way and create a function called is_question_author() in the base theme...

A little late perhaps but to explain the reason for my request, I have 1 category in which members can post a sort of log/journal, which only they can update with answers, and other members can only comment on. It currently only removes the Answer button in that category if the question author is not the current logged in user, will probably have to ensure Answer message box, captcha etc doesn't pop up automatically.

Thanks anyway!
...