Hack: Automatically lock topics in Kunena

Sometimes you may want specific categories to have their topics automatically locked on first post.

Use cases include forum categories for classified ads. So the required behavior here would be to automatically lock a new "for sale" type topic, since for some reasons, e.g. forum rules and terms, you as the forum administrator, do not want replies to be public, but you require that the communication should only be done using personal messages.

Here is the code for the hack:
// automatically lock topic
if ( ($this->parent->catid == ΧΧΧ) && (! $this->parent->id ) ) {
  $this->set ( 'locked', 1 );
  $message = $this->get ( 'message' );
  $message = "[quote]This topic has been automatically locked.
  Please send a pm if you are interested[/quote]\r\n" . $message;
  $this->set ( 'message', $message);

In the code block above, XXX is the category id of the category which will be affected. The category id can be found from Kunena's administration "Category Manager"

The code above also automatically alters the original post and adds a notification in its beginning. You can of course modify the notification, or remove it completely if you don't want a notification in the beginning of the post.

This hack should be placed in:
in function:
immediately after this block of code:
// Fill thread/post related information
$this->set ( 'parent', $this->parent->id );
$this->set ( 'thread', $this->parent->thread );
$this->set ( 'catid', $this->parent->catid );
if (! $this->get ( 'time' ))
$this->set ( 'time', CKunenaTimeformat::internalTime () );


  1. FANTASTIC !!!! is there possibility to delete a post after xx days?


  2. tanie damskie gucci, łącząc elegancki styl i najnowocześniejszą technologię, różnorodność stylów tanie gucci szaliki, wskaźnik przechodzi między Twoim ekskluzywnym stylem smaku.