Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+2 votes
3.1k views
in Plugins by
retagged by

        function filter_answer(&$answer, &$errors, $question, $oldanswer)
        {
              $errors['content'] = 'this is not allowed';
       }
 

not working. What am I missing?

 

From the docs:

As with filter_question(), elements can be added to the $errors array to declare a value invalid.

http://www.question2answer.org/modules.php?module=filter

 

Q2A version: 1.5.4
by
This qa_filter_posts() is the only I am using in the entire q2a setup. And I tried only this plugin code without any "extras".

But what I found out:
1. If I use the code above with an answer on an open question it works. Error message appears.
2. If I use the code above with an answer on a closed question, it does not work.

Could it be that the "core code" intercepts the posted answer if question is closed, and just then the "empty" answer arrives at the filter module?
by
PS: I would not need the filter module if I could change the parentid .... http://www.question2answer.org/qa/26327/
by
Ah, in qa-ajax-answer.php I see that you check before posting the answer:
if ((@$question['basetype']=='Q') && !isset($question['closedbyid'])) { ... }

I changed it to: if (@$question['basetype']=='Q') { ... }
but still does not work.

unbelievable...
by
edited by
I am more and more certain that this issue should be solved in core.

I think there must be many answers being lost because the question got closed while the user was answering, and then s/he got the message that the answer was closed... and her/his answer was gone.

---

Can we just add an else to the qa-ajax-answer.php, in the end after:
if ((@$question['basetype']=='Q') && !isset($question['closedbyid'])) { ... }
and throw an error back to the user, so that s/he will see his answer still opened?

Please log in or register to answer this question.

...