Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+3 votes
464 views
in Q2A Core by
How to lock the question for accepting new answers after selection of best answer by user or moderator?

does this require lots of code changes?

1 Answer

0 votes
by
 
Best answer
This is fairly easy to do - add the following line before the end of the branch:

if (isset($question)) { ... }

at the end of qa_page_q_load_q() in qa-page-question.php:

$question['answerable']=$question['answerable'] && !isset($question['selchildid']);

The && is a logical AND so we're just adding another condition here on whether a question can be answered - the condition is that it has no selected answer.
by
Thanks! its working fine. I feel its good to disable answers on best answer question. anyway user can always put comments if he want and comments can be accepted from registered users.

This will help to fight some SPAM when database grows large.
by
Is it possible to lock questions manually? For example if it's a bad question I'd like to downvote it then lock it, and eventually delete it. If I hide it straight away then the user wouldn't know it was a bad question.
by
btw, how to disable comments also?
by
DisgruntledGoat - there isn't currently a way to lock questions manually.

ProThoughts - you can disable comments by using another line of PHP similar to the one I included:

$question['commentable']=$question['commentable'] && !isset($question['selchildid']);

The full list of characteristics like this are set in qa_page_q_post_rules(...)
by
Thanks again!
by
$question['commentable']=$question['commentable'] && !isset($question['selchildid']);

this line still allows comments on best answer.
by
Gideon, How to fix this issue? thanks!
-------------
 $question['commentable']=$question['commentable'] && !isset($question['selchildid']);

this line still allows comments on best answer.
by
It's the same idea - inside this loop:

foreach ($answers as $key => $answer) { ... }

Insert the code:

$answers[$key]['commentable']=$answer['commentable'] && !isset($question['selchildid']);

I'm assuming here you want to prevent comments on all the answers.
by
yes, once best answer is selected then disable comments on all answers and question. only "ask related question" link should be there.

I guess this should fix the issue.
...