My Q2A site got a lot of people who trying to post spammy, low-quality posts,... in order to earn point because my site have reward at end of the month. One of the most big problem I have is people mark (select) their answer as the best answer. So I went to Stackoverflow to learn how their solve these problem, and I found an very interesting point:
Now, there are some special rules around owner-accepted answers, to prevent gaming:
- Wait 48 hours. You must wait 2 days from the time you originally asked your question before you can accept your own answer. This gives other users a chance to answer the question in good faith, and earn the accepted answer.
Ref: https://meta.stackexchange.com/questions/6044
Sounds good, how to do that?
It's require a little core hacks, because the functions in core we are going to touch in is not allowed to override, so override it via plugin is not possible.
In \qa-include\pages\question-view.php file:
1) Locate line 448 - function qa_page_q_answer_view()
2) Scroll down, locate this part:
if ($question['aselectable'] && !$answer['hidden'] && !$answer['queued']) {
if ($isselected)
$a_view['unselect_tags']='title="'.qa_lang_html('question/unselect_popup').'" name="'.$prefix.'dounselect"'.$clicksuffix;
else
{
$a_view['select_tags']='title="'.qa_lang_html('question/select_popup').'" name="'.$prefix.'doselect"'.$clicksuffix;
}
}
3) Replace the above part with the code below. Note that you can change the error messages by editing the $error variable. And also you can change the limt (2 days) by edit value "4147200", this value is the time count in second.
if ($question['aselectable'] && !$answer['hidden'] && !$answer['queued']) {
if ($isselected)
$a_view['unselect_tags']='title="'.qa_lang_html('question/unselect_popup').'" name="'.$prefix.'dounselect"'.$clicksuffix;
else
{
$a_view['select_tags']='title="'.qa_lang_html('question/select_popup').'" name="'.$prefix.'doselect"'.$clicksuffix;
if ($question['userid'] == $answer['userid'])
if ((strtotime($answer['created'])-strtotime($question['created'])) < 4147200)
{
$error = "'You need to wait for 2 days to select your answer as best answer or waiting answers from your fellow members.'";
$a_view['select_tags']="onclick=\"alert(".$error.");\"";
}
}
}
4) That it! This feature should be working now.
BONUS: And here is what happen when you mark your answer as best answer when not enough 2 days: