Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+4 votes
961 views
in Q2A Core by
I'm creating my own Akismet plugin and I can't quite figure out how to move the post to the moderate section - if the content was detected as spam.

I've looked through the Q2A include files but nothing is jumping out at me.

Could someone post a code snippet how Q2A does it if moderation is enabled?
Q2A version: 1.5

1 Answer

+1 vote
by
 
Best answer

Use a filter module and set the 'queued' field to true if you want it to be queued for moderation.

For example:

function filter_question(&$question, &$errors, $oldquestion)
{
 if (!isset($oldquestion)) // otherwise we're editing an existing one and can't queue for moderation again (this might change in Q2A 1.6)
  if (akismet_thinks_its_spam($question['text']))
   $question['queued']=true;
}

Obviously you have to write the akismet_thinks_its_spam() bit and also reproduce for answers and comments.

by
Thank you, didn't expect it to be that easy :)
by
Just a note to say that in Q2A 1.6 it will be possible for filter modules to re-moderate posts if they have changed. I'll update the docs when appropriate.
by
Thank you for the heads up - I will be ready to update the akismet plugin when those changes go live.
by
I've recently installed 1.6 dev - and if I'm not mistaken, all I need to do is get rid of the "if (!isset($oldquestion))" check and my plugin is good to go for the new version?

Everything appears to be working with just that change, but wanted to double check.
by
Sounds right to me, yes.
...