Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+5 votes
in Q2A Core by
edited by


How to Close question after "x time" ?

In my site, I would like to close question after a couple of days, in order to prevent people answering old question.

Any idea?

Why don't you close it manually?

1 Answer

+1 vote

You write a plugin that checks the database for questions older than x, called one time per day (preferrable by an event that happens by a logged in user).

Then you retrieve the list of questions and you use this function to close them:

    function qa_post_set_closed($questionid, $closed=true, $originalpostid=null, $note=null, $byuserid=null)
    Closed $questionid if $closed is true, otherwise reopen it. If $closed is true, pass either the $originalpostid of
    the question that it is a duplicate of, or a $note to explain why it's closed. Pass the identify of the user in
    $byuserid (or null for an anonymous change).

Thanks but now I close question when a user select the answer as best.